From: Eduardo San Martin Morote Date: Thu, 26 Jan 2023 16:27:59 +0000 (+0100) Subject: docs: migrate en docs X-Git-Tag: v4.2.0~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d89c102b3dfc125b38f2c7a7968003624ffeb7;p=thirdparty%2Fvuejs%2Frouter.git docs: migrate en docs --- diff --git a/package.json b/package.json index b310561a..5ad7c408 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ "p-series": "^3.0.0", "prettier": "^2.8.3", "semver": "^7.3.8", + "typedoc": "^0.23.24", + "typedoc-plugin-markdown": "^3.14.0", "typescript": "~4.9.4", "yorkie": "^2.0.0" }, diff --git a/packages/docs/.gitignore b/packages/docs/.gitignore new file mode 100644 index 00000000..4f2fc4ac --- /dev/null +++ b/packages/docs/.gitignore @@ -0,0 +1 @@ +.vitepress/cache diff --git a/packages/docs/.vitepress/components/VueMasteryVideo.vue b/packages/docs/.vitepress/components/VueMasteryVideo.vue deleted file mode 100644 index 5e43b420..00000000 --- a/packages/docs/.vitepress/components/VueMasteryVideo.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - diff --git a/packages/docs/.vitepress/config.ts b/packages/docs/.vitepress/config.ts deleted file mode 100644 index 398659b7..00000000 --- a/packages/docs/.vitepress/config.ts +++ /dev/null @@ -1,342 +0,0 @@ -import { defineConfig, UserConfig } from 'vitepress' - -const head: UserConfig['head'] = [ - ['link', { rel: 'icon', href: `/logo.png` }], - [ - 'meta', - { name: 'wwads-cn-verify', content: '7e7757b1e12abcb736ab9a754ffb617a' }, - ], - [ - 'script', - { - src: 'https://vueschool.io/banners/main.js', - async: true, - type: 'text/javascript', - }, - ], -] - -if (process.env.NODE_ENV === 'production') { - head.push([ - 'script', - { - src: 'https://unpkg.com/thesemetrics@latest', - async: '', - }, - ]) -} - -const config = defineConfig({ - lang: 'en-US', - title: 'Vue Router', - description: 'The official router for Vue.js.', - head, - // serviceWorker: true, - - locales: { - '/': { - lang: 'en-US', - title: 'Vue Router', - description: 'The official router for Vue.js.', - }, - '/zh/': { - lang: 'zh-CN', - title: 'Vue Router', - description: 'Vue.js 的官方路由', - }, - }, - - themeConfig: { - repo: 'vuejs/router', - docsRepo: 'vuejs/router', - docsDir: 'packages/docs', - docsBranch: 'main', - editLinks: true, - editLinkText: 'Suggest changes to this page', - - carbonAds: { - carbon: 'CEBICK3I', - custom: 'CEBICK3M', - placement: 'routervuejsorg', - }, - - algolia: { - appId: 'BTNTW3I1XP', - apiKey: '771d10c8c5cc48f7922f15048b4d931c', - indexName: 'next_router_vuejs', - // searchParameters: { - // facetFilters: ['tags:guide,api,migration'], - // }, - }, - - locales: { - // English - '/': { - label: 'English', - selectText: 'Languages', - nav: [ - { - text: 'Guide', - link: '/guide/', - }, - { - text: 'API Reference', - link: '/api/', - }, - { - text: 'v4.x', - items: [{ text: 'v3.x', link: 'https://v3.router.vuejs.org' }], - }, - { - text: 'Changelog', - link: 'https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md', - }, - ], - - sidebar: [ - { - text: 'Introduction', - link: '/introduction.html', - }, - { - text: 'Installation', - link: '/installation.html', - }, - { - text: 'Essentials', - collapsable: false, - children: [ - { - text: 'Getting Started', - link: '/guide/', - }, - { - text: 'Dynamic Route Matching', - link: '/guide/essentials/dynamic-matching.html', - }, - { - text: "Routes' Matching Syntax", - link: '/guide/essentials/route-matching-syntax.html', - }, - { - text: 'Nested Routes', - link: '/guide/essentials/nested-routes.html', - }, - { - text: 'Programmatic Navigation', - link: '/guide/essentials/navigation.html', - }, - { - text: 'Named Routes', - link: '/guide/essentials/named-routes.html', - }, - { - text: 'Named Views', - link: '/guide/essentials/named-views.html', - }, - { - text: 'Redirect and Alias', - link: '/guide/essentials/redirect-and-alias.html', - }, - { - text: 'Passing Props to Route Components', - link: '/guide/essentials/passing-props.html', - }, - { - text: 'Different History modes', - link: '/guide/essentials/history-mode.html', - }, - ], - }, - { - text: 'Advanced', - collapsable: false, - children: [ - { - text: 'Navigation guards', - link: '/guide/advanced/navigation-guards.html', - }, - { - text: 'Route Meta Fields', - link: '/guide/advanced/meta.html', - }, - { - text: 'Data Fetching', - link: '/guide/advanced/data-fetching.html', - }, - { - text: 'Composition API', - link: '/guide/advanced/composition-api.html', - }, - { - text: 'Transitions', - link: '/guide/advanced/transitions.html', - }, - { - text: 'Scroll Behavior', - link: '/guide/advanced/scroll-behavior.html', - }, - { - text: 'Lazy Loading Routes', - link: '/guide/advanced/lazy-loading.html', - }, - { - text: 'Typed Routes', - link: '/guide/advanced/typed-routes.html', - }, - { - text: 'Extending RouterLink', - link: '/guide/advanced/extending-router-link.html', - }, - { - text: 'Navigation Failures', - link: '/guide/advanced/navigation-failures.html', - }, - { - text: 'Dynamic Routing', - link: '/guide/advanced/dynamic-routing.html', - }, - ], - }, - { - text: 'Migrating from Vue 2', - link: '/guide/migration/index.html', - }, - ], - }, - // 简体中文 - '/zh/': { - label: '中文', - selectText: '选择语言', - editLinkText: '为此页提供修改建议', - nav: [ - { - text: '教程', - link: '/zh/guide/', - }, - { - text: 'API 参考', - link: '/zh/api/', - }, - { - text: 'v4.x', - items: [{ text: 'v3.x', link: 'https://v3.router.vuejs.org/zh' }], - }, - { - text: '更新日志', - link: 'https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md', - }, - ], - - sidebar: [ - { - text: '介绍', - link: '/zh/introduction.html', - }, - { - text: '安装', - link: '/zh/installation.html', - }, - { - text: '基础', - collapsable: false, - children: [ - { - text: '入门', - link: '/zh/guide/', - }, - { - text: '动态路由匹配', - link: '/zh/guide/essentials/dynamic-matching.html', - }, - { - text: '路由的匹配语法', - link: '/zh/guide/essentials/route-matching-syntax.html', - }, - { - text: '嵌套路由', - link: '/zh/guide/essentials/nested-routes.html', - }, - { - text: '编程式导航', - link: '/zh/guide/essentials/navigation.html', - }, - { - text: '命名路由', - link: '/zh/guide/essentials/named-routes.html', - }, - { - text: '命名视图', - link: '/zh/guide/essentials/named-views.html', - }, - { - text: '重定向和别名', - link: '/zh/guide/essentials/redirect-and-alias.html', - }, - { - text: '路由组件传参', - link: '/zh/guide/essentials/passing-props.html', - }, - { - text: '不同的历史记录模式', - link: '/zh/guide/essentials/history-mode.html', - }, - ], - }, - { - text: '进阶', - collapsable: false, - children: [ - { - text: '导航守卫', - link: '/zh/guide/advanced/navigation-guards.html', - }, - { - text: '路由元信息', - link: '/zh/guide/advanced/meta.html', - }, - { - text: '数据获取', - link: '/zh/guide/advanced/data-fetching.html', - }, - { - text: '组合式 API', - link: '/zh/guide/advanced/composition-api.html', - }, - { - text: '过渡动效', - link: '/zh/guide/advanced/transitions.html', - }, - { - text: '滚动行为', - link: '/zh/guide/advanced/scroll-behavior.html', - }, - { - text: '路由懒加载', - link: '/zh/guide/advanced/lazy-loading.html', - }, - { - text: '扩展 RouterLink', - link: '/zh/guide/advanced/extending-router-link.html', - }, - { - text: '导航故障', - link: '/zh/guide/advanced/navigation-failures.html', - }, - { - text: '动态路由', - link: '/zh/guide/advanced/dynamic-routing.html', - }, - ], - }, - { - text: '从 Vue2 迁移', - link: '/zh/guide/migration/index.html', - }, - ], - }, - }, - }, -}) - -export default config diff --git a/packages/docs/.vitepress/config/en.ts b/packages/docs/.vitepress/config/en.ts new file mode 100644 index 00000000..93b33512 --- /dev/null +++ b/packages/docs/.vitepress/config/en.ts @@ -0,0 +1,189 @@ +import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress' + +export const META_URL = 'https://pinia.vuejs.org' +export const META_TITLE = 'Pinia 🍍' +export const META_DESCRIPTION = + 'Intuitive, type safe, light and flexible Store for Vue' + +export const enConfig: LocaleSpecificConfig = { + description: META_DESCRIPTION, + head: [ + ['meta', { property: 'og:url', content: META_URL }], + ['meta', { property: 'og:description', content: META_DESCRIPTION }], + ['meta', { property: 'twitter:url', content: META_URL }], + ['meta', { property: 'twitter:title', content: META_TITLE }], + ['meta', { property: 'twitter:description', content: META_DESCRIPTION }], + ], + + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/pinia/edit/v2/packages/docs/:path', + text: 'Suggest changes to this page', + }, + + nav: [ + // { text: 'Config', link: '/config/' }, + // { text: 'Plugins', link: '/plugins/' }, + { + text: 'Guide', + link: '/guide/', + activeMatch: '^/guide/', + }, + { text: 'API', link: '/api/', activeMatch: '^/api/' }, + { + text: 'v4.x', + items: [{ text: 'v3.x', link: 'https://v3.router.vuejs.org' }], + }, + { + text: 'Links', + items: [ + { + text: 'Discussions', + link: 'https://github.com/vuejs/router/discussions', + }, + { + text: 'Changelog', + link: 'https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md', + }, + ], + }, + ], + + sidebar: { + // catch-all fallback + '/': [ + { + text: 'Setup', + items: [ + { + text: 'Introduction', + link: '/introduction.html', + }, + { + text: 'Installation', + link: '/installation.html', + }, + ], + }, + { + text: 'Essentials', + collapsible: false, + items: [ + { + text: 'Getting Started', + link: '/guide/', + }, + { + text: 'Dynamic Route Matching', + link: '/guide/essentials/dynamic-matching.html', + }, + { + text: "Routes' Matching Syntax", + link: '/guide/essentials/route-matching-syntax.html', + }, + { + text: 'Nested Routes', + link: '/guide/essentials/nested-routes.html', + }, + { + text: 'Programmatic Navigation', + link: '/guide/essentials/navigation.html', + }, + { + text: 'Named Routes', + link: '/guide/essentials/named-routes.html', + }, + { + text: 'Named Views', + link: '/guide/essentials/named-views.html', + }, + { + text: 'Redirect and Alias', + link: '/guide/essentials/redirect-and-alias.html', + }, + { + text: 'Passing Props to Route Components', + link: '/guide/essentials/passing-props.html', + }, + { + text: 'Different History modes', + link: '/guide/essentials/history-mode.html', + }, + ], + }, + { + text: 'Advanced', + collapsible: false, + items: [ + { + text: 'Navigation guards', + link: '/guide/advanced/navigation-guards.html', + }, + { + text: 'Route Meta Fields', + link: '/guide/advanced/meta.html', + }, + { + text: 'Data Fetching', + link: '/guide/advanced/data-fetching.html', + }, + { + text: 'Composition API', + link: '/guide/advanced/composition-api.html', + }, + { + text: 'Transitions', + link: '/guide/advanced/transitions.html', + }, + { + text: 'Scroll Behavior', + link: '/guide/advanced/scroll-behavior.html', + }, + { + text: 'Lazy Loading Routes', + link: '/guide/advanced/lazy-loading.html', + }, + { + text: 'Typed Routes', + link: '/guide/advanced/typed-routes.html', + }, + { + text: 'Extending RouterLink', + link: '/guide/advanced/extending-router-link.html', + }, + { + text: 'Navigation Failures', + link: '/guide/advanced/navigation-failures.html', + }, + { + text: 'Dynamic Routing', + link: '/guide/advanced/dynamic-routing.html', + }, + ], + }, + { + items: [ + { + text: 'Migrating from Vue 2', + link: '/guide/migration/index.html', + }, + ], + }, + ], + + // '/api/': [ + // { + // text: 'packages', + // items: [ + // { text: 'pinia', link: '/api/modules/pinia.html' }, + // { text: '@pinia/nuxt', link: '/api/modules/pinia_nuxt.html' }, + // { + // text: '@pinia/testing', + // link: '/api/modules/pinia_testing.html', + // }, + // ], + // }, + // ], + }, + }, +} diff --git a/packages/docs/.vitepress/config/index.ts b/packages/docs/.vitepress/config/index.ts new file mode 100644 index 00000000..99288735 --- /dev/null +++ b/packages/docs/.vitepress/config/index.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vitepress' +import { enConfig } from './en' +import { sharedConfig } from './shared' +import { zhConfig } from './zh' + +export default defineConfig({ + ...sharedConfig, + + locales: { + root: { label: 'English', lang: 'en-US', link: '/', ...enConfig }, + // zh: { label: '简体中文', lang: 'zh-CN', link: '/zh/', ...zhConfig }, + }, +}) diff --git a/packages/docs/.vitepress/config/shared.ts b/packages/docs/.vitepress/config/shared.ts new file mode 100644 index 00000000..bdf6d172 --- /dev/null +++ b/packages/docs/.vitepress/config/shared.ts @@ -0,0 +1,121 @@ +import { defineConfig, HeadConfig } from 'vitepress' + +export const META_IMAGE = 'https://pinia.vuejs.org/social.png' +export const isProduction = + process.env.NETLIFY && process.env.CONTEXT === 'production' + +if (process.env.NETLIFY) { + console.log('Netlify build', process.env.CONTEXT) +} + +const productionHead: HeadConfig[] = [ + [ + 'script', + { + src: 'https://unpkg.com/thesemetrics@latest', + async: '', + type: 'text/javascript', + }, + ], +] + +export const sharedConfig = defineConfig({ + title: 'Vue Router', + appearance: 'dark', + + markdown: { + theme: { + dark: 'one-dark-pro', + light: 'github-light', + }, + + attrs: { + leftDelimiter: '%{', + rightDelimiter: '}%', + }, + }, + + head: [ + ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], + ['link', { rel: 'icon', type: 'image/png', href: '/logo.png' }], + + [ + 'meta', + { name: 'wwads-cn-verify', content: '7e7757b1e12abcb736ab9a754ffb617a' }, + ], + + [ + 'meta', + { + property: 'og:type', + content: 'website', + }, + ], + + [ + 'meta', + { + property: 'twitter:card', + content: 'summary_large_image', + }, + ], + [ + 'meta', + { + property: 'twitter:image', + content: META_IMAGE, + }, + ], + + [ + 'script', + { + src: 'https://vueschool.io/banners/main.js', + // @ts-expect-error: vitepress bug + async: true, + type: 'text/javascript', + }, + ], + + ...(isProduction ? productionHead : []), + ], + + themeConfig: { + logo: '/logo.svg', + outline: [2, 3], + + socialLinks: [ + { icon: 'twitter', link: 'https://twitter.com/posva' }, + { + icon: 'github', + link: 'https://github.com/vuejs/router', + }, + { + icon: 'discord', + link: 'https://chat.vuejs.org', + }, + ], + + footer: { + copyright: 'Copyright © 2014-present Evan You, Eduardo San Martin Morote', + message: 'Released under the MIT License.', + }, + + editLink: { + pattern: 'https://github.com/vuejs/router/edit/main/packages/docs/:path', + text: 'Suggest changes', + }, + + algolia: { + appId: 'BTNTW3I1XP', + apiKey: '771d10c8c5cc48f7922f15048b4d931c', + indexName: 'next_router_vuejs', + }, + + carbonAds: { + code: 'CEBICK3I', + // custom: 'CEBICK3M', + placement: 'routervuejsorg', + }, + }, +}) diff --git a/packages/docs/.vitepress/config/zh.ts b/packages/docs/.vitepress/config/zh.ts new file mode 100644 index 00000000..60b62f88 --- /dev/null +++ b/packages/docs/.vitepress/config/zh.ts @@ -0,0 +1,148 @@ +import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress' + +export const META_URL = 'https://pinia.vuejs.org' +export const META_TITLE = 'Pinia 🍍' +export const META_DESCRIPTION = '值得你喜欢的 Vue Store' +// TODO: translation of this +// 'Intuitive, type safe, light and flexible Store for Vue' + +export const zhConfig: LocaleSpecificConfig = { + description: META_DESCRIPTION, + head: [ + ['meta', { property: 'og:url', content: META_URL }], + ['meta', { property: 'og:description', content: META_DESCRIPTION }], + ['meta', { property: 'twitter:url', content: META_URL }], + ['meta', { property: 'twitter:title', content: META_TITLE }], + ['meta', { property: 'twitter:description', content: META_DESCRIPTION }], + ], + + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/pinia/edit/v2/packages/docs/:path', + text: '对本页提出修改建议', + }, + + outlineTitle: '本页内容', + + nav: [ + // { text: 'Config', link: '/config/' }, + // { text: 'Plugins', link: '/plugins/' }, + { + text: '指南', + link: '/zh/core-concepts/', + activeMatch: '^/zh/core-concepts/', + }, + { text: 'API', link: '/zh/api/', activeMatch: '^/zh/api/' }, + { text: '手册', link: '/zh/cookbook/', activeMatch: '^/zh/cookbook/' }, + { + text: '相关链接', + items: [ + { + text: '论坛', + link: 'https://github.com/vuejs/pinia/discussions', + }, + { + text: '更新日志', + link: 'https://github.com/vuejs/pinia/blob/v2/packages/pinia/CHANGELOG.md', + }, + ], + }, + ], + sidebar: { + '/zh/api/': [ + { + text: 'packages', + items: [ + { text: 'pinia', link: '/zh/api/modules/pinia.html' }, + { text: '@pinia/nuxt', link: '/zh/api/modules/pinia_nuxt.html' }, + { + text: '@pinia/testing', + link: '/zh/api/modules/pinia_testing.html', + }, + ], + }, + ], + '/zh/': [ + { + text: '介绍', + items: [ + { + text: 'Pinia 是什么?', + link: '/zh/introduction.html', + }, + { + text: '开始', + link: '/zh/getting-started.html', + }, + ], + }, + { + text: '核心概念', + items: [ + { text: '定义 Store', link: '/zh/core-concepts/' }, + { text: 'State', link: '/zh/core-concepts/state.html' }, + { text: 'Getter', link: '/zh/core-concepts/getters.html' }, + { text: 'Action', link: '/zh/core-concepts/actions.html' }, + { text: '插件', link: '/zh/core-concepts/plugins.html' }, + { + text: '组件外的 Store', + link: '/zh/core-concepts/outside-component-usage.html', + }, + ], + }, + { + text: '服务端渲染 (SSR)', + items: [ + { + text: 'Vue 与 Vite', + link: '/zh/ssr/', + }, + { + text: 'Nuxt.js', + link: '/zh/ssr/nuxt.html', + }, + ], + }, + { + text: '手册', + collapsible: true, + collapsed: false, + items: [ + { + text: '目录', + link: '/zh/cookbook/', + }, + { + text: '从 Vuex ≤4 迁移', + link: '/zh/cookbook/migration-vuex.html', + }, + { + text: '热更新', + link: '/zh/cookbook/hot-module-replacement.html', + }, + { + text: '测试', + link: '/zh/cookbook/testing.html', + }, + { + text: '不使用 setup() 的用法', + link: '/zh/cookbook/options-api.html', + }, + { + text: '组合式 Stores', + link: '/zh/cookbook/composing-stores.html', + }, + { + text: '从 v0/v1 迁移至 v2', + link: '/zh/cookbook/migration-v1-v2.html', + }, + { + text: '处理组合式函数', + link: '/zh/cookbook/composables.html', + }, + ], + }, + ], + }, + }, +} diff --git a/packages/docs/.vitepress/style.styl b/packages/docs/.vitepress/style.styl deleted file mode 100644 index 4a91b368..00000000 --- a/packages/docs/.vitepress/style.styl +++ /dev/null @@ -1,53 +0,0 @@ -.bit-sponsor - font-weight 600 - background-color #f3f6f8 - padding 0.6em 1.2em - border-radius 8px - display inline-block - margin 1em 0 !important - - a - color #999 - - img - height 40px - margin-left 15px - - img, span - vertical-align middle - -.vueschool - background-color #e7ecf3 - padding 1em 1.25em - border-radius 2px - color #486491 - position relative - display flex - - a - color #486491 !important - position relative - padding-left 36px - - &:before - content '' - position absolute - display block - width 30px - height 30px - top calc(50% - 15px); - left -4px - border-radius 50% - background-color #73abfe - - &:after - content '' - position absolute - display block - width 0 - height 0 - top calc(50% - 5px) - left 8px - border-top 5px solid transparent - border-bottom 5px solid transparent - border-left 8px solid #fff diff --git a/packages/docs/.vitepress/theme/Layout.vue b/packages/docs/.vitepress/theme/Layout.vue deleted file mode 100644 index 66dd099c..00000000 --- a/packages/docs/.vitepress/theme/Layout.vue +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - diff --git a/packages/docs/.vitepress/theme/banner-top.css b/packages/docs/.vitepress/theme/banner-top.css deleted file mode 100644 index c71ea837..00000000 --- a/packages/docs/.vitepress/theme/banner-top.css +++ /dev/null @@ -1,6 +0,0 @@ -.has-top-banner, -.has-top-banner .nav-bar, -.has-top-banner .sidebar, -.has-top-banner .page { - margin-top: 72px; -} \ No newline at end of file diff --git a/packages/docs/.vitepress/components/HomeSponsors.vue b/packages/docs/.vitepress/theme/components/HomeSponsors.vue similarity index 50% rename from packages/docs/.vitepress/components/HomeSponsors.vue rename to packages/docs/.vitepress/theme/components/HomeSponsors.vue index 05295d63..458b02c7 100644 --- a/packages/docs/.vitepress/components/HomeSponsors.vue +++ b/packages/docs/.vitepress/theme/components/HomeSponsors.vue @@ -1,28 +1,37 @@ - + + + + diff --git a/packages/docs/.vitepress/components/VueMasteryHomeLink.vue b/packages/docs/.vitepress/theme/components/VueMasteryHomeLink.vue similarity index 73% rename from packages/docs/.vitepress/components/VueMasteryHomeLink.vue rename to packages/docs/.vitepress/theme/components/VueMasteryHomeLink.vue index 5b2fa0e0..6bde6b7c 100644 --- a/packages/docs/.vitepress/components/VueMasteryHomeLink.vue +++ b/packages/docs/.vitepress/theme/components/VueMasteryHomeLink.vue @@ -4,61 +4,55 @@ - \ No newline at end of file + diff --git a/packages/docs/.vitepress/components/VueSchoolLink.vue b/packages/docs/.vitepress/theme/components/VueSchoolLink.vue similarity index 90% rename from packages/docs/.vitepress/components/VueSchoolLink.vue rename to packages/docs/.vitepress/theme/components/VueSchoolLink.vue index 02843450..e5211f55 100644 --- a/packages/docs/.vitepress/components/VueSchoolLink.vue +++ b/packages/docs/.vitepress/theme/components/VueSchoolLink.vue @@ -6,7 +6,7 @@ rel="sponsored noopener" :title="title" > - {{ translations[site.lang]}} + {{ translations[site.lang] }} @@ -23,15 +23,13 @@ defineProps<{ href: string; title: string }>()