Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i18n): fix locales reading, add site.langs #353

Merged
merged 7 commits into from
Aug 20, 2021
Merged

fix(i18n): fix locales reading, add site.langs #353

merged 7 commits into from
Aug 20, 2021

Conversation

posva
Copy link
Member

@posva posva commented Aug 5, 2021

Still need some unit/integration tests:

Tested with the following config:

module.exports = {
  // lang: 'en-US',
  // title: 'VitePress',
  // description: 'Vite & Vue powered static site generator.',

  locales: {
    '/': {
      lang: 'en-US',
      title: 'VitePress',
      description: 'Vite & Vue powered static site generator.'
    },
    '/zh/': {
      lang: 'zh-CN',
      title: '中文 Vitepress',
      description: '中文 description'
    }
  },

  themeConfig: {
    repo: 'vuejs/vitepress',
    docsDir: 'docs',
    editLinks: true,
    algolia: {
      apiKey: 'c57105e511faa5558547599f120ceeba',
      indexName: 'vitepress'
    },

    carbonAds: {
      carbon: 'CEBDT27Y',
      custom: 'CKYD62QM',
      placement: 'vuejsorg'
    },

    locales: {
      '/': {
        editLinkText: 'Edit this page on GitHub',
        lastUpdated: 'Last Updated',
        label: 'English',

        nav: [
          { text: 'Guide', link: '/', activeMatch: '^/$|^/guide/' },
          {
            text: 'Config Reference',
            link: '/config/basics',
            activeMatch: '^/config/'
          },
          {
            text: 'Release Notes',
            link: 'https://github.com/vuejs/vitepress/releases'
          }
        ],

        sidebar: {
          '/guide/': getGuideSidebar(),
          '/config/': getConfigSidebar(),
          '/': getGuideSidebar()
        }
      },
      '/zh/': {
        editLinkText: 'Edit this page on GitHub',
        lastUpdated: 'Last Updated',
        label: '中文',

        nav: [
          { text: 'Guide', link: '/zh/', activeMatch: '^/$|^/guide/' },
          {
            text: 'Release Notes',
            link: 'https://github.com/vuejs/vitepress/releases'
          }
        ],

        sidebar: {
          '/guide/': getGuideSidebar(),
          '/config/': getConfigSidebar(),
          '/': getGuideSidebar()
        }
      }
    }
  }
}

function getGuideSidebar() {
  return [
    {
      text: 'Introduction',
      children: [
        { text: 'What is VitePress?', link: '/' },
        { text: 'Getting Started', link: '/guide/getting-started' },
        { text: 'Configuration', link: '/guide/configuration' },
        { text: 'Asset Handling', link: '/guide/assets' },
        { text: 'Markdown Extensions', link: '/guide/markdown' },
        { text: 'Using Vue in Markdown', link: '/guide/using-vue' },
        { text: 'Deploying', link: '/guide/deploy' }
      ]
    },
    {
      text: 'Advanced',
      children: [
        { text: 'Frontmatter', link: '/guide/frontmatter' },
        { text: 'Theming', link: '/guide/theming' },
        { text: 'API Reference', link: '/guide/api' },
        {
          text: 'Differences from Vuepress',
          link: '/guide/differences-from-vuepress'
        }
      ]
    }
  ]
}

function getConfigSidebar() {
  return [
    {
      text: 'App Config',
      children: [{ text: 'Basics', link: '/config/basics' }]
    },
    {
      text: 'Theme Config',
      children: [
        { text: 'Homepage', link: '/config/homepage' },
        { text: 'Algolia Search', link: '/config/algolia-search' },
        { text: 'Carbon Ads', link: '/config/carbon-ads' }
      ]
    }
  ]
}

@posva posva mentioned this pull request Aug 18, 2021
3 tasks
@posva posva merged commit bc78adb into master Aug 20, 2021
@posva posva deleted the fix/locales branch August 20, 2021 10:08
YunYouJun pushed a commit to YunYouJun/vitepress that referenced this pull request Aug 30, 2021
It works with the same config as Vuepress 1: https://vuepress.vuejs.org/guide/i18n.html#site-level-i18n-config

We could probably adapt the `label` property like Vuepress 2 https://v2.vuepress.vuejs.org/guide/i18n.html#site-i18n-config in a next release
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant