Tell VitePress to prefix each route with the current locale

177 Views Asked by At

I have a VitePress project supporting multiple languages. This is an example for the german language

import { defineConfig } from 'vitepress'

export default defineConfig({
    title: 'Project',
    themeConfig: {
        i18nRouting: true
    },
    locales: {
        de: {
            label: 'German',
            lang: 'de',
            themeConfig: {
                nav: [
                    { text: 'Eins', link: '/de/one/' }
                ],
                sidebar: {
                    '/de/one/': [
                        {
                            text: 'Eins',
                            items: [
                                { text: 'Startseite', link: '/de/one/' }
                            ]
                        }
                    ],
                }
            },
        }
    }
})

The navigation only works when I prefix each route with the locale, e.g. /de/...

Reproduction link

Is there a way to tell VitePress to do that for me since it already knows the themeConfig only refers to the german locale?

0

There are 0 best solutions below