You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardexpand all lines: packages/docs/docs/theme/README.md
+13-3
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Just one `Layout.vue` might not be enough, and you might also want to define mor
28
28
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
29
29
30
30
::: vue
31
-
theme
31
+
themePath
32
32
βββ `global-components`_(**Optional**)_
33
33
β βββ xxx.vue
34
34
βββ `components`_(**Optional**)_
@@ -42,7 +42,7 @@ theme
42
42
βββ `templates`_(**Optional**)_
43
43
β Β βββ dev.html
44
44
β Β βββ ssr.html
45
-
βββ `index.js`_(**Optional**)_
45
+
βββ `index.js`_(**Only required when you publish it as an npm package**)_
46
46
βββ `enhanceApp.js`_(**Optional**)_
47
47
βββ package.json
48
48
:::
@@ -56,7 +56,17 @@ theme
56
56
-`theme/enhanceApp.js`: Theme level enhancements.
57
57
58
58
::: warning Note
59
-
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.
59
+
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.
60
+
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).
Copy file name to clipboardexpand all lines: packages/docs/docs/zh/theme/README.md
+16-4
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ sidebar: auto
4
4
5
5
# Theme
6
6
7
+
> Translation are welcome!
8
+
7
9
::: tip
8
10
Theme components are subject to the same [browser API access restrictions](../guide/using-vue.md#browser-api-access-restrictions).
9
11
:::
@@ -28,7 +30,7 @@ Just one `Layout.vue` might not be enough, and you might also want to define mor
28
30
So it's time to reorganize your theme, an agreed theme directory structure is as follows:
29
31
30
32
::: vue
31
-
theme
33
+
themePath
32
34
βββ `global-components`_(**Optional**)_
33
35
β βββ xxx.vue
34
36
βββ `components`_(**Optional**)_
@@ -42,21 +44,31 @@ theme
42
44
βββ `templates`_(**Optional**)_
43
45
β Β βββ dev.html
44
46
β Β βββ ssr.html
45
-
βββ `index.js`_(**Optional**)_
47
+
βββ `index.js`_(**Only required when you publish it as an npm package**)_
46
48
βββ `enhanceApp.js`_(**Optional**)_
47
49
βββ package.json
48
50
:::
49
51
50
52
-`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).
51
53
-`theme/components`: Your components.
52
54
-`theme/layouts`: Layout components of the theme, where `Layout.vue` is required.
53
-
-`theme/styles`: Global style and palette.
55
+
-`theme/styles`: Global style and palette.
54
56
-`theme/templates`: Modify default template.
55
57
-`theme/index.js`: Entry file of theme configuration.
56
58
-`theme/enhanceApp.js`: Theme level enhancements.
57
59
58
60
::: warning Note
59
-
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.
61
+
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.
62
+
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).
0 commit comments