Skip to content

Populate matcher function with inherited slugs #4500

Open
@ghost

Description

Describe the problem

I'll just describe my situation: My SvelteKit site is supposed to be localised into multiple (predefined) languages. To archive that I created this SvelteKit route layout: /src/pages/[...locale=locale]/[about=about].svelte. Implementing the locale slug was pretty easy thanks to the recent addition of matchers (In this case my matcher only returns true if [ "", "de", "lv" ] includes locale), but now comes the tricky part: I obviously also want to localise the urls of individual pages, but this isn't possible without knowing the locale slug.

Describe the proposed solution

match() could receive a second argument, called params. params would be an object with the same layout as event.params in handle().

export function match(param, params) {
    return {
        "": "about",
        "de": "uber",
        "lv": "par"
    }[params.locale] === param
}

Alternatives considered

Currently it should be possible to create a store to make inheriting possible. While this works it definitely is a workaround.

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions