From 8999abab5f15dbebc30257a73d04e129cc0cc583 Mon Sep 17 00:00:00 2001 From: Peter Uithoven Date: Tue, 25 Aug 2020 09:17:18 +0200 Subject: [PATCH] docs: clarify theme config files in code blocks (close #2533) (#2534) --- packages/docs/docs/theme/default-theme-config.md | 8 ++++++++ packages/docs/docs/theme/inheritance.md | 7 ++++--- packages/docs/docs/theme/option-api.md | 7 +++++-- packages/docs/docs/theme/using-a-theme.md | 5 +++++ packages/docs/docs/theme/writing-a-theme.md | 1 + packages/docs/docs/zh/theme/default-theme-config.md | 9 ++++++++- packages/docs/docs/zh/theme/inheritance.md | 8 ++++---- packages/docs/docs/zh/theme/option-api.md | 7 +++++-- packages/docs/docs/zh/theme/using-a-theme.md | 5 +++++ packages/docs/docs/zh/theme/writing-a-theme.md | 3 ++- 10 files changed, 47 insertions(+), 13 deletions(-) diff --git a/packages/docs/docs/theme/default-theme-config.md b/packages/docs/docs/theme/default-theme-config.md index f868c6cfcb..e64da69a72 100644 --- a/packages/docs/docs/theme/default-theme-config.md +++ b/packages/docs/docs/theme/default-theme-config.md @@ -86,6 +86,7 @@ module.exports = { These links can also be dropdown menus if you provide an array of `items` instead of a `link`: ```js +// .vuepress/config.js module.exports = { themeConfig: { nav: [ @@ -105,6 +106,7 @@ module.exports = { You can also have sub groups inside a dropdown by having nested items: ```js +// .vuepress/config.js module.exports = { themeConfig: { nav: [ @@ -177,6 +179,7 @@ sidebarDepth: 2 The sidebar only displays links for headers in the current active page. You can display all header links for every page with `themeConfig.displayAllHeaders: true`: ``` js +// .vuepress/config.js module.exports = { themeConfig: { displayAllHeaders: true // Default: false @@ -189,6 +192,7 @@ module.exports = { By default, the nested header links and the hash in the URL are updated as the user scrolls to view the different sections of the page. This behavior can be disabled with the following theme config: ``` js +// .vuepress/config.js module.exports = { themeConfig: { activeHeaderLinks: false, // Default: true @@ -346,6 +350,7 @@ sidebar: false You can disable the built-in search box with `themeConfig.search: false`, and customize how many suggestions will be shown with `themeConfig.searchMaxSuggestions`: ``` js +// .vuepress/config.js module.exports = { themeConfig: { search: false, @@ -383,6 +388,7 @@ If you need full text search, you can use [Algolia Search](#algolia-search). The `themeConfig.algolia` option allows you to use [Algolia DocSearch](https://community.algolia.com/docsearch/) to replace the simple built-in search. To enable it, you need to provide at least `apiKey` and `indexName`: ``` js +// .vuepress/config.js module.exports = { themeConfig: { algolia: { @@ -404,6 +410,7 @@ For more options, check out [Algolia DocSearch’s documentation](https://github You can define a placeholder for the search box by adding the `searchPlaceholder` attribute: ``` js +// .vuepress/config.js module.exports = { themeConfig: { searchPlaceholder: 'Search...' @@ -416,6 +423,7 @@ module.exports = { The `themeConfig.lastUpdated` option allows you to get the UNIX timestamp(ms) of each file’s last `git` commit, and it will also display at the bottom of each page in an appropriate format: ``` js +// .vuepress/config.js module.exports = { themeConfig: { lastUpdated: 'Last Updated', // string | boolean diff --git a/packages/docs/docs/theme/inheritance.md b/packages/docs/docs/theme/inheritance.md index ca095341da..f18778437d 100644 --- a/packages/docs/docs/theme/inheritance.md +++ b/packages/docs/docs/theme/inheritance.md @@ -28,6 +28,7 @@ For now theme inheritance doesn’t support high-order inheritance, that means, Suppose you want to create a theme inherited from the default theme, you only need to configure the [extend](./option-api.md#extend) option in your theme configuration: ```js +// .vuepress/theme/index.js module.exports = { extend: '@vuepress/theme-default' } @@ -79,7 +80,7 @@ module.exports = { The child theme can edit the options of plugin in the following ways: ```js -// themePath/index.js +// .vuepress/theme/index.js module.exports = { plugins: [ ['@vuepress/search', { @@ -92,7 +93,7 @@ module.exports = { Child theme can even disable it: ```js -// themePath/index.js +// .vuepress/theme/index.js module.exports = { plugins: [ ['@vuepress/search', false] @@ -160,7 +161,7 @@ This way, you can "tamper" with some part of an atomic theme. You can use `@parent-theme` to access the root path of the parent theme. The following example shows creating a layout component with the same name in a child theme and using slots in the parent theme. [@vuepress/theme-vue](https://github.com/vuejs/vuepress/tree/master/packages/%40vuepress/theme-vue) is created in this way. ```vue - +