diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 3cf6255e..23eeac47 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -16,8 +16,7 @@ export default defineConfig({ }, editLink: { - repo: 'vuejs/vitepress', - dir: 'docs', + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', text: 'Edit this page on GitHub' }, diff --git a/docs/config/frontmatter-configs.md b/docs/config/frontmatter-configs.md index d57e6cba..25dd222c 100644 --- a/docs/config/frontmatter-configs.md +++ b/docs/config/frontmatter-configs.md @@ -76,6 +76,19 @@ type Head = | [string, Record, string] ``` +## lastUpdated + +- Type: `boolean` +- Default: `true` + +Whether to display [Last Updated](../guide/theme-last-updated) text in the current page. + +```yaml +--- +lastUpdated: false +--- +``` + ## layout - Type: `doc | home | page` diff --git a/docs/config/theme-configs.md b/docs/config/theme-configs.md index 17c24708..37564b78 100644 --- a/docs/config/theme-configs.md +++ b/docs/config/theme-configs.md @@ -188,6 +188,30 @@ export interface Footer { } ``` +## editLink + +- Type: `EditLink` + +Edit Link lets you display a link to edit the page on Git management services such as GitHub, or GitLab. See [Theme: Edit Link](../guide/theme-edit-link) for more details. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', + text: 'Edit this page on GitHub' + } + } +} +``` + +```ts +export interface EditLink { + pattern: string + text?: string +} +``` + ## lastUpdatedText - Type: `string` diff --git a/docs/guide/theme-edit-link.md b/docs/guide/theme-edit-link.md index 39eba214..64e74b31 100644 --- a/docs/guide/theme-edit-link.md +++ b/docs/guide/theme-edit-link.md @@ -1,3 +1,28 @@ # Edit Link -Documentation coming soon... +Edit Link lets you display a link to edit the page on Git management services such as GitHub, or GitLab. To enable it, add `themeConfig.editLink` options to your config. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path' + } + } +} +``` + +The `pattern` option defines the URL structure for the link, and `:path` is going to be replaced with the page path. + +By default, this will add the link text "Edit this page" at the bottom of the doc page. You may customize this text by defining the `text` option. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', + text: 'Edit this page on GitHub' + } + } +} +``` diff --git a/docs/guide/theme-sidebar.md b/docs/guide/theme-sidebar.md index 3a2c853d..1433c05d 100644 --- a/docs/guide/theme-sidebar.md +++ b/docs/guide/theme-sidebar.md @@ -68,7 +68,7 @@ export default { ## Multiple Sidebars -You may show different sidebar depending on the page path. For example, as shown on this site, you might want to create a separate sections of content in your documentation like "Guide" page and `Config` page. +You may show different sidebar depending on the page path. For example, as shown on this site, you might want to create a separate sections of content in your documentation like "Guide" page and "Config" page. To do so, first organize your pages into directories for each desired section: @@ -92,27 +92,31 @@ export default { sidebar: { // This sidebar gets displayed when user is // under `guide` directory. - '/guide/': { - text: 'Guide', - items: [ - // This shows `/guide/index.md` page. - { text: 'Index', link: '/guide/' }, // /guide/index.md - { text: 'One', link: '/guide/one' }, // /guide/one.md - { text: 'Two', link: '/guide/two' } // /guide/two.md - ] - }, + '/guide/': [ + { + text: 'Guide', + items: [ + // This shows `/guide/index.md` page. + { text: 'Index', link: '/guide/' }, // /guide/index.md + { text: 'One', link: '/guide/one' }, // /guide/one.md + { text: 'Two', link: '/guide/two' } // /guide/two.md + ] + } + ], // This sidebar gets displayed when user is // under `config` directory. - '/config/': { - text: 'Config', - items: [ - // This shows `/guide/index.md` page. - { text: 'Index', link: '/config/' }, // /config/index.mdasdfasdfasdfasdfaf - { text: 'Three', link: '/config/three' }, // /config/three.md - { text: 'Four', link: '/config/four' } // /config/four.md - ] - } + '/config/': [ + { + text: 'Config', + items: [ + // This shows `/guide/index.md` page. + { text: 'Index', link: '/config/' }, // /config/index.md + { text: 'Three', link: '/config/three' }, // /config/three.md + { text: 'Four', link: '/config/four' } // /config/four.md + ] + } + ] } } } diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue index d6c5d246..e1d3408a 100644 --- a/src/client/theme-default/components/VPButton.vue +++ b/src/client/theme-default/components/VPButton.vue @@ -1,5 +1,6 @@