From 7759d54ccbc67500456382eb7fb9c68e55e457ff Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Thu, 18 Oct 2018 03:30:06 +0800 Subject: [PATCH] docs: declare that `themePath/index.js` is required When you want to publish your theme as an npm package, make sure the package has `index.js`, and set `"main"` field at `package.json` to `index.js` so that VuePress can resolve and get the correct themePath. --- packages/docs/docs/theme/README.md | 16 +++++++++++++--- packages/docs/docs/zh/plugin/README.md | 2 +- packages/docs/docs/zh/theme/README.md | 20 ++++++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/docs/docs/theme/README.md b/packages/docs/docs/theme/README.md index 0d263c51a1..499d445114 100644 --- a/packages/docs/docs/theme/README.md +++ b/packages/docs/docs/theme/README.md @@ -28,7 +28,7 @@ Just one `Layout.vue` might not be enough, and you might also want to define mor So it's time to reorganize your theme, an agreed theme directory structure is as follows: ::: vue -theme +themePath ├── `global-components` _(**Optional**)_ │ └── xxx.vue ├── `components` _(**Optional**)_ @@ -42,7 +42,7 @@ theme ├── `templates` _(**Optional**)_ │   ├── dev.html │   └── ssr.html -├── `index.js` _(**Optional**)_ +├── `index.js` _(**Only required when you publish it as an npm package**)_ ├── `enhanceApp.js` _(**Optional**)_ └── package.json ::: @@ -56,7 +56,17 @@ theme - `theme/enhanceApp.js`: Theme level enhancements. ::: warning Note -Considering backward compatibility, Vue components located at theme root directory will also be automatically registered as layout components. But the recommended is placing them under `layouts` directory, which looks more clearer. +1. Considering backward compatibility, Vue components located at [themePath](../miscellaneous/glossary.md#theme-side) will also be automatically registered as layout components. But the recommended is placing them under `themePath/layouts` directory, which looks more clearer. +2. When you want to publish your theme as an npm package, make sure the package has `index.js`, and set `"main"` field at `package.json` to `index.js` so that VuePress can resolve and get the correct [themePath](../miscellaneous/glossary.md#theme-side). + +```json +{ + ... + "main": "index.js" + ... +} +``` + ::: ### Layout Component diff --git a/packages/docs/docs/zh/plugin/README.md b/packages/docs/docs/zh/plugin/README.md index 6058770765..a0fefabc35 100644 --- a/packages/docs/docs/zh/plugin/README.md +++ b/packages/docs/docs/zh/plugin/README.md @@ -4,7 +4,7 @@ sidebar: auto # Plugins -> To be translated soon. +> Translation are welcome! ## Writing a Plugin diff --git a/packages/docs/docs/zh/theme/README.md b/packages/docs/docs/zh/theme/README.md index 0d263c51a1..0c29d65976 100644 --- a/packages/docs/docs/zh/theme/README.md +++ b/packages/docs/docs/zh/theme/README.md @@ -4,6 +4,8 @@ sidebar: auto # Theme +> Translation are welcome! + ::: tip Theme components are subject to the same [browser API access restrictions](../guide/using-vue.md#browser-api-access-restrictions). ::: @@ -28,7 +30,7 @@ Just one `Layout.vue` might not be enough, and you might also want to define mor So it's time to reorganize your theme, an agreed theme directory structure is as follows: ::: vue -theme +themePath ├── `global-components` _(**Optional**)_ │ └── xxx.vue ├── `components` _(**Optional**)_ @@ -42,7 +44,7 @@ theme ├── `templates` _(**Optional**)_ │   ├── dev.html │   └── ssr.html -├── `index.js` _(**Optional**)_ +├── `index.js` _(**Only required when you publish it as an npm package**)_ ├── `enhanceApp.js` _(**Optional**)_ └── package.json ::: @@ -50,13 +52,23 @@ theme - `theme/global-components`: Components under this directory will be automatically registered as global components. For details, please refer to [@vuepress/plugin-register-components](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-register-components). - `theme/components`: Your components. - `theme/layouts`: Layout components of the theme, where `Layout.vue` is required. -- `theme/styles`: Global style and palette. +- `theme/styles`: Global style and palette. - `theme/templates`: Modify default template. - `theme/index.js`: Entry file of theme configuration. - `theme/enhanceApp.js`: Theme level enhancements. ::: warning Note -Considering backward compatibility, Vue components located at theme root directory will also be automatically registered as layout components. But the recommended is placing them under `layouts` directory, which looks more clearer. +1. Considering backward compatibility, Vue components located at [themePath](../miscellaneous/glossary.md#theme-side) will also be automatically registered as layout components. But the recommended is placing them under `themePath/layouts` directory, which looks more clearer. +2. When you want to publish your theme as an npm package, make sure the package has `index.js`, and set `"main"` field at `package.json` to `index.js` so that VuePress can resolve and get the correct [themePath](../miscellaneous/glossary.md#theme-side). + +```json +{ + ... + "main": "index.js" + ... +} +``` + ::: ### Layout Component