question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

localizePath and ids

See original GitHub issue

Hi, when using localizePath with and id in it (#contact for instance), it adds an / at the end. Here is a workaround I’ve made but not ideal:

return href.startsWith('#') ? href : localizePath(href)

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
florian-lefebvrecommented, Dec 21, 2022

I would refactor is a little bit like so:

---
import { localizePath } from 'astro-i18next'
const links = [
    {
        href: '#solutions',
        name: 'Solutions',
    },
    {
        href: '#enfoque',
        name: 'Enfoque',
    },
    {
        href: '#nosotros',
        name: 'Nosotros',
    },
    {
        href: '/blog',
        name: 'Blog',
    },
    {
        href: '#contactanos',
        name: 'Contactanos',
        active: true,
    },
].map(({ href, name, active }) => ({
    name,
    active,
    href: href.startsWith('#') ? href : localizePath(href),
}))
---

<ul
    tabindex="0"
    class="menu menu-compact dropdown-content bg-base-100 rounded-box mt-3 w-52 p-2 shadow"
>
    {
        links.map(({ href, name, active }) => (
            <li>
                <a
                    class={active ? 'text-primary font-bold' : null}
                    href={localizePath(href)}
                >
                    {name}
                </a>
            </li>
        ))
    }
</ul>
1reaction
yassinedoghricommented, Dec 10, 2022

Thank you for the issue, this is a duplicate of #77, so closing this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

florian-lefebvre (Florian LEFEBVRE) - GitHub
localizePath and ids. Hi, when using localizePath with and id in it ( #contact for instance), it adds an / at the end....
Read more >
Q100491: Automatically localizing files from multiple paths
This article outlines how you can automatically localize files from multiple different paths as, currently, Nuke's 'auto-localize from' feature ...
Read more >
Localizing the visitor group criterion - Optimizely
This topic describes how to localize your own visitor group criteria.
Read more >
Job API - SideFX
localizePath (deloc_path) → str. Localizes the specified path. When Path Mapping is disabled, this function replaces any __PDG* tokens.
Read more >
RouteCollection - CodeIgniter v4.0.0 API
fillRouteParams() : string: Given a; loadRoutesOptions() : array<string|int, mixed>: Load routes options based on verb; localizeRoute() : string: Replaces ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found