@vuepress/client 2.0.0-beta.5 → 2.0.0-beta.50-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +48 -16
- package/CHANGELOG.md +0 -187
- package/lib/app.d.ts +0 -18
- package/lib/app.js +0 -132
- package/lib/client.d.ts +0 -1
- package/lib/client.js +0 -14
- package/lib/components/Content.d.ts +0 -7
- package/lib/components/Content.js +0 -34
- package/lib/components/OutboundLink.css +0 -7
- package/lib/components/OutboundLink.d.ts +0 -3
- package/lib/components/OutboundLink.js +0 -24
- package/lib/components/Vuepress.d.ts +0 -5
- package/lib/components/Vuepress.js +0 -33
- package/lib/components/index.d.ts +0 -3
- package/lib/components/index.js +0 -3
- package/lib/constants.d.ts +0 -4
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -5
- package/lib/injections/index.d.ts +0 -10
- package/lib/injections/index.js +0 -10
- package/lib/injections/pageData.d.ts +0 -7
- package/lib/injections/pageData.js +0 -31
- package/lib/injections/pageFrontmatter.d.ts +0 -7
- package/lib/injections/pageFrontmatter.js +0 -10
- package/lib/injections/pageHead.d.ts +0 -15
- package/lib/injections/pageHead.js +0 -33
- package/lib/injections/pageHeadTitle.d.ts +0 -11
- package/lib/injections/pageHeadTitle.js +0 -13
- package/lib/injections/pageLang.d.ts +0 -13
- package/lib/injections/pageLang.js +0 -16
- package/lib/injections/pagesData.d.ts +0 -6
- package/lib/injections/pagesData.js +0 -6
- package/lib/injections/routeLocale.d.ts +0 -10
- package/lib/injections/routeLocale.js +0 -14
- package/lib/injections/siteData.d.ts +0 -6
- package/lib/injections/siteData.js +0 -10
- package/lib/injections/siteLocaleData.d.ts +0 -12
- package/lib/injections/siteLocaleData.js +0 -17
- package/lib/injections/updateHead.d.ts +0 -15
- package/lib/injections/updateHead.js +0 -100
- package/lib/server.d.ts +0 -8
- package/lib/server.js +0 -10
- package/lib/types/clientAppEnhance.d.ts +0 -8
- package/lib/types/clientAppEnhance.js +0 -1
- package/lib/types/clientAppSetup.d.ts +0 -1
- package/lib/types/clientAppSetup.js +0 -1
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.js +0 -2
- package/lib/types/internal/clientAppEnhances.d.ts +0 -5
- package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
- package/lib/types/internal/clientAppSetups.d.ts +0 -5
- package/lib/types/internal/layoutComponents.d.ts +0 -5
- package/lib/types/internal/pagesComponent.d.ts +0 -5
- package/lib/types/internal/pagesData.d.ts +0 -5
- package/lib/types/internal/pagesRoutes.d.ts +0 -5
- package/lib/types/internal/siteData.d.ts +0 -5
- package/lib/utils/defineClientAppEnhance.d.ts +0 -2
- package/lib/utils/defineClientAppEnhance.js +0 -1
- package/lib/utils/defineClientAppSetup.d.ts +0 -2
- package/lib/utils/defineClientAppSetup.js +0 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -3
- package/lib/utils/withBase.d.ts +0 -4
- package/lib/utils/withBase.js +0 -11
- package/templates/index.dev.html +0 -8
- package/templates/index.ssr.html +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/client",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.50-pre",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -15,25 +15,57 @@
|
|
|
15
15
|
"url": "git+https://github.com/vuepress/vuepress-next.git"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"author": "
|
|
19
|
-
"
|
|
20
|
-
"
|
|
18
|
+
"author": "meteorlxy",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./app": "./dist/app.js",
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
"./templates/*": "./templates/*",
|
|
25
|
+
"./types": "./types.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
21
30
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"templates"
|
|
31
|
+
"./dist",
|
|
32
|
+
"./templates",
|
|
33
|
+
"./types.d.ts"
|
|
24
34
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc -b tsconfig.build.json",
|
|
27
|
-
"clean": "rimraf lib *.tsbuildinfo",
|
|
28
|
-
"copy": "cpx \"src/**/*.{d.ts,css}\" lib"
|
|
29
|
-
},
|
|
30
35
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"vue
|
|
36
|
+
"@vue/devtools-api": "^6.2.1",
|
|
37
|
+
"@vuepress/shared": "2.0.0-beta.50-pre",
|
|
38
|
+
"vue": "^3.2.37",
|
|
39
|
+
"vue-router": "^4.1.3"
|
|
34
40
|
},
|
|
35
41
|
"publishConfig": {
|
|
36
42
|
"access": "public"
|
|
37
43
|
},
|
|
38
|
-
"
|
|
39
|
-
|
|
44
|
+
"tsup": {
|
|
45
|
+
"clean": true,
|
|
46
|
+
"dts": "./src/index.ts",
|
|
47
|
+
"entry": [
|
|
48
|
+
"./src/app.ts",
|
|
49
|
+
"./src/index.ts"
|
|
50
|
+
],
|
|
51
|
+
"external": [
|
|
52
|
+
"@internal/clientConfigs",
|
|
53
|
+
"@internal/layoutComponents",
|
|
54
|
+
"@internal/pagesComponents",
|
|
55
|
+
"@internal/pagesData",
|
|
56
|
+
"@internal/pagesRoutes",
|
|
57
|
+
"@internal/siteData"
|
|
58
|
+
],
|
|
59
|
+
"format": [
|
|
60
|
+
"esm"
|
|
61
|
+
],
|
|
62
|
+
"outDir": "./dist",
|
|
63
|
+
"sourcemap": false,
|
|
64
|
+
"target": "es2020",
|
|
65
|
+
"tsconfig": "./tsconfig.dts.json"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsup",
|
|
69
|
+
"clean": "rimraf dist"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [2.0.0-beta.5](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2021-03-26)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **client:** ensure page component is loaded before route resolve ([598adf3](https://github.com/vuepress/vuepress-next/commit/598adf38b1f9edd3034bb011358a1a9d3bcb6b9e))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### Performance Improvements
|
|
15
|
-
|
|
16
|
-
* improve HMR support ([38f0073](https://github.com/vuepress/vuepress-next/commit/38f007335864db4c9125ea5905ca91850fb7103b))
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# [2.0.0-beta.4](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2021-03-20)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @vuepress/client
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [2.0.0-beta.1](https://github.com/vuepress/vuepress-next/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2021-03-13)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @vuepress/client
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# [2.0.0-beta.0](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.26...v2.0.0-beta.0) (2021-03-13)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Features
|
|
42
|
-
|
|
43
|
-
* implement vite hmr ([525c18d](https://github.com/vuepress/vuepress-next/commit/525c18d5a64fbdbdeb5ce1348ec1e1ead3dbd8f9))
|
|
44
|
-
* **client:** add defineClientAppEnhance and defineClientAppSetup utils ([1520517](https://github.com/vuepress/vuepress-next/commit/15205172c3b56fc8a879bba040f4ecc815d2c924))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# [2.0.0-alpha.25](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.24...v2.0.0-alpha.25) (2021-02-20)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Code Refactoring
|
|
54
|
-
|
|
55
|
-
* **core:** remove theme data from site data ([187aef3](https://github.com/vuepress/vuepress-next/commit/187aef36607efc62d7b2d5c773553f89685cf64c))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### BREAKING CHANGES
|
|
59
|
-
|
|
60
|
-
* **core:** `themeConfig` is not available in site data any more
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# [2.0.0-alpha.24](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.23...v2.0.0-alpha.24) (2021-02-13)
|
|
67
|
-
|
|
68
|
-
**Note:** Version bump only for package @vuepress/client
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# [2.0.0-alpha.22](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.21...v2.0.0-alpha.22) (2021-02-10)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
### Bug Fixes
|
|
78
|
-
|
|
79
|
-
* **client:** only watch route path to update head ([3174f5a](https://github.com/vuepress/vuepress-next/commit/3174f5a676d95943df256b2be31227eb844d0144))
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# [2.0.0-alpha.20](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.19...v2.0.0-alpha.20) (2021-02-04)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### Features
|
|
89
|
-
|
|
90
|
-
* **core:** make language available in page data ([03bb09f](https://github.com/vuepress/vuepress-next/commit/03bb09fd51aeaff56d26820a1401b87ea8bdeb38))
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
# [2.0.0-alpha.19](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.18...v2.0.0-alpha.19) (2021-01-24)
|
|
97
|
-
|
|
98
|
-
**Note:** Version bump only for package @vuepress/client
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# [2.0.0-alpha.18](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2021-01-17)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
### Bug Fixes
|
|
108
|
-
|
|
109
|
-
* **client:** load existing head tags on mounted ([15722c5](https://github.com/vuepress/vuepress-next/commit/15722c5175e44a8d6363bfe5f138f2c2c8edeec3))
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
### Features
|
|
113
|
-
|
|
114
|
-
* **client:** make usePageFrontmatter generic ([2c5e5c1](https://github.com/vuepress/vuepress-next/commit/2c5e5c1400469a3cb4da2856104514a9413bff8a))
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# [2.0.0-alpha.16](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.15...v2.0.0-alpha.16) (2021-01-11)
|
|
121
|
-
|
|
122
|
-
**Note:** Version bump only for package @vuepress/client
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
# [2.0.0-alpha.15](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.14...v2.0.0-alpha.15) (2021-01-04)
|
|
129
|
-
|
|
130
|
-
**Note:** Version bump only for package @vuepress/client
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
# [2.0.0-alpha.13](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.12...v2.0.0-alpha.13) (2020-12-23)
|
|
137
|
-
|
|
138
|
-
**Note:** Version bump only for package @vuepress/client
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
# [2.0.0-alpha.7](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2020-12-09)
|
|
145
|
-
|
|
146
|
-
**Note:** Version bump only for package @vuepress/client
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# [2.0.0-alpha.6](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2020-12-09)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
### Features
|
|
156
|
-
|
|
157
|
-
* **client:** remove built-in debug component ([a5962bb](https://github.com/vuepress/vuepress-next/commit/a5962bb82483f56800b33b4e35c50dcb49fd48b1))
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
# 2.0.0-alpha.1 (2020-12-01)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
### Bug Fixes
|
|
167
|
-
|
|
168
|
-
* **client:** do not prepend base to http url ([9e4e623](https://github.com/vuepress/vuepress-next/commit/9e4e6233ce988bf3b6ebbbb1bc60f83a26f6709c))
|
|
169
|
-
* **client:** wrap ssr-app with a parent div ([c65b6c4](https://github.com/vuepress/vuepress-next/commit/c65b6c47f084466dde9daf17d1c1d00b88f6682d))
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
### Features
|
|
173
|
-
|
|
174
|
-
* **client:** add built-in styles for Debug component ([1b3b028](https://github.com/vuepress/vuepress-next/commit/1b3b028e0cd078eb6f074c36696255df1cf49267))
|
|
175
|
-
* **client:** add ClientOnly component ([e2cad36](https://github.com/vuepress/vuepress-next/commit/e2cad36c5f859240e5fac62c38fbaa14b39defab))
|
|
176
|
-
* **client:** add global computed and updateHead ([df83b88](https://github.com/vuepress/vuepress-next/commit/df83b887a69db9290a22d0731056f4ac2b6f0014))
|
|
177
|
-
* **client:** add global data utils ([46b9fc5](https://github.com/vuepress/vuepress-next/commit/46b9fc579f51c1f037f4850f8699074805799884))
|
|
178
|
-
* **client:** add OutboundLink component ([4107add](https://github.com/vuepress/vuepress-next/commit/4107add516e7acd0cbdc4a526bf4772c54fb6108))
|
|
179
|
-
* **client:** add siteLocale in debug component ([e1d663b](https://github.com/vuepress/vuepress-next/commit/e1d663b4ece27012c72383f5eecb90c5fb2195ef))
|
|
180
|
-
* **client:** add themeData injections ([04cafe2](https://github.com/vuepress/vuepress-next/commit/04cafe23ec835d9efc9a2b1ab8be8b7d8f0a22b4))
|
|
181
|
-
* **client:** add withBase util ([f234c5d](https://github.com/vuepress/vuepress-next/commit/f234c5d74f148b55b265d13dc2c868d8531d192a))
|
|
182
|
-
* **client:** augment route meta type ([6f4e1f5](https://github.com/vuepress/vuepress-next/commit/6f4e1f5995351a0dd6ebf257e1889d26e77d26e4))
|
|
183
|
-
* **client:** make siteData injections generic ([86b9416](https://github.com/vuepress/vuepress-next/commit/86b941646b7554b404a621a3616a7a81958c12c3))
|
|
184
|
-
* **client:** provide site locale data ([00455bd](https://github.com/vuepress/vuepress-next/commit/00455bdf21736254c8a3a488cdf8245e80742398))
|
|
185
|
-
* **client:** set scrollBehavior for vue-router ([f7a12ce](https://github.com/vuepress/vuepress-next/commit/f7a12ceaa1e20ba2e87fa34c692a754fcc3f34f4))
|
|
186
|
-
* **client:** support clientAppRootComponentFiles ([188c1a0](https://github.com/vuepress/vuepress-next/commit/188c1a04fed8ed6614b45a6a0c1cb3d07a4ca112))
|
|
187
|
-
* **client:** take 404 as the fallback layout ([bb34903](https://github.com/vuepress/vuepress-next/commit/bb349038da090d0e5fd9069ff5cfa3372c95dc0b))
|
package/lib/app.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CreateAppFunction, App } from 'vue';
|
|
2
|
-
import type { Router, RouterHistory } from 'vue-router';
|
|
3
|
-
export declare type AppCreator = CreateAppFunction<Element>;
|
|
4
|
-
export declare type HistoryCreator = (base?: string) => RouterHistory;
|
|
5
|
-
export declare type CreateVueAppResult = {
|
|
6
|
-
app: App;
|
|
7
|
-
router: Router;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Create a vue app
|
|
11
|
-
*
|
|
12
|
-
* Accepting different app creator and history creator, so it
|
|
13
|
-
* can be reused for both client side and server side
|
|
14
|
-
*/
|
|
15
|
-
export declare const createVueApp: ({ appCreator, historyCreator, }: {
|
|
16
|
-
appCreator: AppCreator;
|
|
17
|
-
historyCreator: HistoryCreator;
|
|
18
|
-
}) => Promise<CreateVueAppResult>;
|
package/lib/app.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { computed, h } from 'vue';
|
|
2
|
-
import { createRouter, RouterView, START_LOCATION } from 'vue-router';
|
|
3
|
-
import { clientAppEnhances } from '@internal/clientAppEnhances';
|
|
4
|
-
import { clientAppRootComponents } from '@internal/clientAppRootComponents';
|
|
5
|
-
import { clientAppSetups } from '@internal/clientAppSetups';
|
|
6
|
-
import { pagesComponent } from '@internal/pagesComponent';
|
|
7
|
-
import { pagesRoutes } from '@internal/pagesRoutes';
|
|
8
|
-
import { siteData, pageData, resolvePageData, pageFrontmatterSymbol, resolvePageFrontmatter, pageHeadSymbol, resolvePageHead, pageHeadTitleSymbol, resolvePageHeadTitle, pageLangSymbol, resolvePageLang, routeLocaleSymbol, resolveRouteLocale, siteLocaleDataSymbol, resolveSiteLocaleData, useUpdateHead, } from './injections';
|
|
9
|
-
import { Content, OutboundLink } from './components';
|
|
10
|
-
import { withBase } from './utils';
|
|
11
|
-
/**
|
|
12
|
-
* Create a vue app
|
|
13
|
-
*
|
|
14
|
-
* Accepting different app creator and history creator, so it
|
|
15
|
-
* can be reused for both client side and server side
|
|
16
|
-
*/
|
|
17
|
-
export const createVueApp = async ({ appCreator, historyCreator, }) => {
|
|
18
|
-
// options to create vue app
|
|
19
|
-
const appOptions = {
|
|
20
|
-
setup() {
|
|
21
|
-
// auto update head
|
|
22
|
-
useUpdateHead();
|
|
23
|
-
// invoke all clientAppSetups
|
|
24
|
-
for (const clientAppSetup of clientAppSetups) {
|
|
25
|
-
clientAppSetup();
|
|
26
|
-
}
|
|
27
|
-
return () => [
|
|
28
|
-
h(RouterView),
|
|
29
|
-
...clientAppRootComponents.map((comp) => h(comp)),
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
// create vue app
|
|
34
|
-
const app = appCreator(appOptions);
|
|
35
|
-
// create vue-router
|
|
36
|
-
const router = createRouter({
|
|
37
|
-
history: historyCreator(siteData.value.base),
|
|
38
|
-
routes: pagesRoutes,
|
|
39
|
-
scrollBehavior: (to, from, savedPosition) => {
|
|
40
|
-
if (savedPosition) {
|
|
41
|
-
return savedPosition;
|
|
42
|
-
}
|
|
43
|
-
if (to.hash) {
|
|
44
|
-
return { el: to.hash };
|
|
45
|
-
}
|
|
46
|
-
return { top: 0 };
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
// use vue-router
|
|
50
|
-
app.use(router);
|
|
51
|
-
router.beforeResolve(async (to, from) => {
|
|
52
|
-
if (to.path !== from.path || from === START_LOCATION) {
|
|
53
|
-
// ensure page data and page component have been loaded
|
|
54
|
-
;
|
|
55
|
-
[pageData.value] = await Promise.all([
|
|
56
|
-
resolvePageData(to.path),
|
|
57
|
-
pagesComponent[to.path].__asyncLoader(),
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
// create global computed
|
|
62
|
-
const routeLocale = computed(() => resolveRouteLocale(siteData.value.locales, router.currentRoute.value.path));
|
|
63
|
-
const siteLocaleData = computed(() => resolveSiteLocaleData(siteData.value, routeLocale.value));
|
|
64
|
-
const pageFrontmatter = computed(() => resolvePageFrontmatter(pageData.value));
|
|
65
|
-
const pageHeadTitle = computed(() => resolvePageHeadTitle(pageData.value, siteLocaleData.value));
|
|
66
|
-
const pageHead = computed(() => resolvePageHead(pageHeadTitle.value, pageFrontmatter.value, siteLocaleData.value));
|
|
67
|
-
const pageLang = computed(() => resolvePageLang(pageData.value));
|
|
68
|
-
// provide global computed
|
|
69
|
-
app.provide(routeLocaleSymbol, routeLocale);
|
|
70
|
-
app.provide(siteLocaleDataSymbol, siteLocaleData);
|
|
71
|
-
app.provide(pageFrontmatterSymbol, pageFrontmatter);
|
|
72
|
-
app.provide(pageHeadTitleSymbol, pageHeadTitle);
|
|
73
|
-
app.provide(pageHeadSymbol, pageHead);
|
|
74
|
-
app.provide(pageLangSymbol, pageLang);
|
|
75
|
-
// provide global data & helpers
|
|
76
|
-
Object.defineProperties(app.config.globalProperties, {
|
|
77
|
-
$routeLocale: {
|
|
78
|
-
get() {
|
|
79
|
-
return routeLocale.value;
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
$site: {
|
|
83
|
-
get() {
|
|
84
|
-
return siteData.value;
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
$siteLocale: {
|
|
88
|
-
get() {
|
|
89
|
-
return siteLocaleData.value;
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
$page: {
|
|
93
|
-
get() {
|
|
94
|
-
return pageData.value;
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
$frontmatter: {
|
|
98
|
-
get() {
|
|
99
|
-
return pageFrontmatter.value;
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
$lang: {
|
|
103
|
-
get() {
|
|
104
|
-
return pageLang.value;
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
$headTitle: {
|
|
108
|
-
get() {
|
|
109
|
-
return pageHeadTitle.value;
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
$withBase: {
|
|
113
|
-
get() {
|
|
114
|
-
return withBase;
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
// register built-in components
|
|
119
|
-
/* eslint-disable vue/match-component-file-name */
|
|
120
|
-
app.component('ClientOnly', __SSR__ ? () => null : (_, ctx) => { var _a, _b; return (_b = (_a = ctx.slots).default) === null || _b === void 0 ? void 0 : _b.call(_a); });
|
|
121
|
-
app.component('Content', Content);
|
|
122
|
-
app.component('OutboundLink', OutboundLink);
|
|
123
|
-
/* eslint-enable vue/match-component-file-name */
|
|
124
|
-
// invoke all clientAppEnhances
|
|
125
|
-
for (const clientAppEnhance of clientAppEnhances) {
|
|
126
|
-
await clientAppEnhance({ app, router, siteData });
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
app,
|
|
130
|
-
router,
|
|
131
|
-
};
|
|
132
|
-
};
|
package/lib/client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/client.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createApp } from 'vue';
|
|
2
|
-
import { createWebHistory } from 'vue-router';
|
|
3
|
-
import { createVueApp } from './app';
|
|
4
|
-
/**
|
|
5
|
-
* Client entry point
|
|
6
|
-
*/
|
|
7
|
-
createVueApp({
|
|
8
|
-
appCreator: createApp,
|
|
9
|
-
historyCreator: createWebHistory,
|
|
10
|
-
}).then(({ app, router }) => {
|
|
11
|
-
router.isReady().then(() => {
|
|
12
|
-
app.mount('#app');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { pagesComponent } from '@internal/pagesComponent';
|
|
3
|
-
import { usePageData } from '../injections';
|
|
4
|
-
/**
|
|
5
|
-
* Markdown rendered content
|
|
6
|
-
*/
|
|
7
|
-
export const Content = (props) => {
|
|
8
|
-
let key;
|
|
9
|
-
// use the page key from props directly
|
|
10
|
-
if (props.pagePath) {
|
|
11
|
-
key = props.pagePath;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// get current page key from page data
|
|
15
|
-
const page = usePageData();
|
|
16
|
-
key = page.value.path;
|
|
17
|
-
}
|
|
18
|
-
const component = pagesComponent[key];
|
|
19
|
-
// use page component
|
|
20
|
-
if (component) {
|
|
21
|
-
return h(component);
|
|
22
|
-
}
|
|
23
|
-
// fallback
|
|
24
|
-
return h('div', __DEV__
|
|
25
|
-
? 'Page does not exist. This is a fallback content.'
|
|
26
|
-
: '404 Not Found');
|
|
27
|
-
};
|
|
28
|
-
Content.displayName = 'Content';
|
|
29
|
-
Content.props = {
|
|
30
|
-
pagePath: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import './OutboundLink.css';
|
|
3
|
-
const svg = h('svg', {
|
|
4
|
-
class: 'icon outbound',
|
|
5
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
6
|
-
ariaHidden: 'true',
|
|
7
|
-
focusable: 'false',
|
|
8
|
-
x: '0px',
|
|
9
|
-
y: '0px',
|
|
10
|
-
viewBox: '0 0 100 100',
|
|
11
|
-
width: '15',
|
|
12
|
-
height: '15',
|
|
13
|
-
}, [
|
|
14
|
-
h('path', {
|
|
15
|
-
fill: 'currentColor',
|
|
16
|
-
d: 'M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z',
|
|
17
|
-
}),
|
|
18
|
-
h('polygon', {
|
|
19
|
-
fill: 'currentColor',
|
|
20
|
-
points: '45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9',
|
|
21
|
-
}),
|
|
22
|
-
]);
|
|
23
|
-
export const OutboundLink = (_, { slots }) => { var _a; return h('span', [svg, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]); };
|
|
24
|
-
OutboundLink.displayName = 'OutboundLink';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { isString } from '@vuepress/shared';
|
|
3
|
-
import { layoutComponents } from '@internal/layoutComponents';
|
|
4
|
-
import { usePageData } from '../injections';
|
|
5
|
-
import { Content } from './Content';
|
|
6
|
-
/**
|
|
7
|
-
* Global Layout
|
|
8
|
-
*/
|
|
9
|
-
export const Vuepress = () => {
|
|
10
|
-
// get layout of current page
|
|
11
|
-
let layoutName = '404';
|
|
12
|
-
const page = usePageData();
|
|
13
|
-
if (page.value.path) {
|
|
14
|
-
// if current page exists
|
|
15
|
-
// use layout from frontmatter
|
|
16
|
-
const frontmatterLayout = page.value.frontmatter.layout;
|
|
17
|
-
if (isString(frontmatterLayout)) {
|
|
18
|
-
layoutName = frontmatterLayout;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// fallback to Layout component
|
|
22
|
-
layoutName = 'Layout';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const layoutComponent = layoutComponents[layoutName];
|
|
26
|
-
// use layout component
|
|
27
|
-
if (layoutComponent) {
|
|
28
|
-
return h(layoutComponent);
|
|
29
|
-
}
|
|
30
|
-
// fallback to Content
|
|
31
|
-
return h(Content);
|
|
32
|
-
};
|
|
33
|
-
Vuepress.displayName = 'Vuepress';
|
package/lib/components/index.js
DELETED
package/lib/constants.d.ts
DELETED
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './pageData';
|
|
2
|
-
export * from './pageFrontmatter';
|
|
3
|
-
export * from './pageHead';
|
|
4
|
-
export * from './pageHeadTitle';
|
|
5
|
-
export * from './pageLang';
|
|
6
|
-
export * from './pagesData';
|
|
7
|
-
export * from './routeLocale';
|
|
8
|
-
export * from './siteData';
|
|
9
|
-
export * from './siteLocaleData';
|
|
10
|
-
export * from './updateHead';
|
package/lib/injections/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './pageData';
|
|
2
|
-
export * from './pageFrontmatter';
|
|
3
|
-
export * from './pageHead';
|
|
4
|
-
export * from './pageHeadTitle';
|
|
5
|
-
export * from './pageLang';
|
|
6
|
-
export * from './pagesData';
|
|
7
|
-
export * from './routeLocale';
|
|
8
|
-
export * from './siteData';
|
|
9
|
-
export * from './siteLocaleData';
|
|
10
|
-
export * from './updateHead';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export type { PageData };
|
|
4
|
-
export declare type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageData<T>>;
|
|
5
|
-
export declare const pageData: PageDataRef;
|
|
6
|
-
export declare const usePageData: <T extends Record<any, any> = Record<never, never>>() => PageDataRef<T>;
|
|
7
|
-
export declare const resolvePageData: (routePath: string) => Promise<PageData>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ref, readonly } from 'vue';
|
|
2
|
-
import { pagesData } from './pagesData';
|
|
3
|
-
const pageDataEmpty = readonly({
|
|
4
|
-
key: '',
|
|
5
|
-
path: '',
|
|
6
|
-
title: '',
|
|
7
|
-
lang: '',
|
|
8
|
-
frontmatter: {},
|
|
9
|
-
excerpt: '',
|
|
10
|
-
headers: [],
|
|
11
|
-
});
|
|
12
|
-
export const pageData = ref(pageDataEmpty);
|
|
13
|
-
export const usePageData = () => {
|
|
14
|
-
return pageData;
|
|
15
|
-
};
|
|
16
|
-
export const resolvePageData = async (routePath) => {
|
|
17
|
-
const pageDataResolver = pagesData.value[routePath];
|
|
18
|
-
if (!pageDataResolver) {
|
|
19
|
-
return pageDataEmpty;
|
|
20
|
-
}
|
|
21
|
-
const pageData = await pageDataResolver();
|
|
22
|
-
return pageData !== null && pageData !== void 0 ? pageData : pageDataEmpty;
|
|
23
|
-
};
|
|
24
|
-
if (import.meta.webpackHot || import.meta.hot) {
|
|
25
|
-
// reuse vue HMR runtime
|
|
26
|
-
__VUE_HMR_RUNTIME__.updatePageData = (data) => {
|
|
27
|
-
if (data.key === pageData.value.key) {
|
|
28
|
-
pageData.value = data;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData, PageFrontmatter } from '@vuepress/shared';
|
|
3
|
-
export type { PageFrontmatter };
|
|
4
|
-
export declare type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
|
|
5
|
-
export declare const pageFrontmatterSymbol: InjectionKey<PageFrontmatterRef>;
|
|
6
|
-
export declare const usePageFrontmatter: <T extends Record<any, any> = Record<string, unknown>>() => PageFrontmatterRef<T>;
|
|
7
|
-
export declare const resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageFrontmatterSymbol = Symbol(__DEV__ ? 'pageFrontmatter' : '');
|
|
3
|
-
export const usePageFrontmatter = () => {
|
|
4
|
-
const pageFrontmatter = inject(pageFrontmatterSymbol);
|
|
5
|
-
if (!pageFrontmatter) {
|
|
6
|
-
throw new Error('usePageFrontmatter() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageFrontmatter;
|
|
9
|
-
};
|
|
10
|
-
export const resolvePageFrontmatter = (pageData) => pageData.frontmatter;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { HeadConfig } from '@vuepress/shared';
|
|
3
|
-
import type { PageFrontmatter } from './pageFrontmatter';
|
|
4
|
-
import type { PageHeadTitle } from './pageHeadTitle';
|
|
5
|
-
import type { SiteLocaleData } from './siteLocaleData';
|
|
6
|
-
export declare type PageHead = HeadConfig[];
|
|
7
|
-
export declare type PageHeadRef = ComputedRef<PageHead>;
|
|
8
|
-
export declare const pageHeadSymbol: InjectionKey<PageHeadRef>;
|
|
9
|
-
export declare const usePageHead: () => PageHeadRef;
|
|
10
|
-
/**
|
|
11
|
-
* Merge the head config in frontmatter and site locale
|
|
12
|
-
*
|
|
13
|
-
* Frontmatter should take priority over site locale
|
|
14
|
-
*/
|
|
15
|
-
export declare const resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => HeadConfig[];
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import { dedupeHead, isArray, isString } from '@vuepress/shared';
|
|
3
|
-
export const pageHeadSymbol = Symbol(__DEV__ ? 'pageHead' : '');
|
|
4
|
-
export const usePageHead = () => {
|
|
5
|
-
const pageHead = inject(pageHeadSymbol);
|
|
6
|
-
if (!pageHead) {
|
|
7
|
-
throw new Error('usePageHead() is called without provider.');
|
|
8
|
-
}
|
|
9
|
-
return pageHead;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Merge the head config in frontmatter and site locale
|
|
13
|
-
*
|
|
14
|
-
* Frontmatter should take priority over site locale
|
|
15
|
-
*/
|
|
16
|
-
export const resolvePageHead = (headTitle, frontmatter, siteLocale) => {
|
|
17
|
-
const description = isString(frontmatter.description)
|
|
18
|
-
? frontmatter.description
|
|
19
|
-
: siteLocale.description;
|
|
20
|
-
const head = [
|
|
21
|
-
...(isArray(frontmatter.head) ? frontmatter.head : []),
|
|
22
|
-
...siteLocale.head,
|
|
23
|
-
['title', {}, headTitle],
|
|
24
|
-
['meta', { name: 'description', content: description }],
|
|
25
|
-
['meta', { charset: 'utf-8' }],
|
|
26
|
-
[
|
|
27
|
-
'meta',
|
|
28
|
-
{ name: 'viewport', content: 'width=device-width,initial-scale=1' },
|
|
29
|
-
],
|
|
30
|
-
['meta', { name: 'generator', content: `VuePress ${__VERSION__}` }],
|
|
31
|
-
];
|
|
32
|
-
return dedupeHead(head);
|
|
33
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData } from './pageData';
|
|
3
|
-
import type { SiteLocaleData } from './siteLocaleData';
|
|
4
|
-
export declare type PageHeadTitle = string;
|
|
5
|
-
export declare type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
|
|
6
|
-
export declare const pageHeadTitleSymbol: InjectionKey<PageHeadTitleRef>;
|
|
7
|
-
export declare const usePageHeadTitle: () => PageHeadTitleRef;
|
|
8
|
-
/**
|
|
9
|
-
* Title to displayed in `<head>` tag
|
|
10
|
-
*/
|
|
11
|
-
export declare const resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageHeadTitleSymbol = Symbol(__DEV__ ? 'pageHeadTitle' : '');
|
|
3
|
-
export const usePageHeadTitle = () => {
|
|
4
|
-
const pageHeadTitle = inject(pageHeadTitleSymbol);
|
|
5
|
-
if (!pageHeadTitle) {
|
|
6
|
-
throw new Error('usePageHeadTitle() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageHeadTitle;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Title to displayed in `<head>` tag
|
|
12
|
-
*/
|
|
13
|
-
export const resolvePageHeadTitle = (page, siteLocale) => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export declare type PageLang = string;
|
|
4
|
-
export declare type PageLangRef = ComputedRef<PageLang>;
|
|
5
|
-
export declare const pageLangSymbol: InjectionKey<PageLangRef>;
|
|
6
|
-
export declare const usePageLang: () => PageLangRef;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve language of current page
|
|
9
|
-
*
|
|
10
|
-
* It's mainly used for the `lang` attribute of `<html>` tag,
|
|
11
|
-
* which should not be empty
|
|
12
|
-
*/
|
|
13
|
-
export declare const resolvePageLang: (pageData: PageData) => PageLang;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageLangSymbol = Symbol(__DEV__ ? 'pageLang' : '');
|
|
3
|
-
export const usePageLang = () => {
|
|
4
|
-
const pageLang = inject(pageLangSymbol);
|
|
5
|
-
if (!pageLang) {
|
|
6
|
-
throw new Error('usePageLang() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageLang;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Resolve language of current page
|
|
12
|
-
*
|
|
13
|
-
* It's mainly used for the `lang` attribute of `<html>` tag,
|
|
14
|
-
* which should not be empty
|
|
15
|
-
*/
|
|
16
|
-
export const resolvePageLang = (pageData) => pageData.lang || 'en';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export declare type PagesData = Record<string, () => Promise<PageData>>;
|
|
4
|
-
export declare type PagesDataRef = Ref<PagesData>;
|
|
5
|
-
export declare const pagesData: PagesDataRef;
|
|
6
|
-
export declare const usePagesData: () => PagesDataRef;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
export declare type RouteLocale = string;
|
|
4
|
-
export declare type RouteLocaleRef = ComputedRef<RouteLocale>;
|
|
5
|
-
export declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
|
|
6
|
-
export declare const useRouteLocale: () => RouteLocaleRef;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve locale path of the route path
|
|
9
|
-
*/
|
|
10
|
-
export declare const resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import { resolveLocalePath } from '@vuepress/shared';
|
|
3
|
-
export const routeLocaleSymbol = Symbol(__DEV__ ? 'routeLocale' : '');
|
|
4
|
-
export const useRouteLocale = () => {
|
|
5
|
-
const routeLocale = inject(routeLocaleSymbol);
|
|
6
|
-
if (!routeLocale) {
|
|
7
|
-
throw new Error('useRouteLocale() is called without provider.');
|
|
8
|
-
}
|
|
9
|
-
return routeLocale;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Resolve locale path of the route path
|
|
13
|
-
*/
|
|
14
|
-
export const resolveRouteLocale = (locales, routePath) => resolveLocalePath(locales, routePath);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { readonly, ref } from 'vue';
|
|
2
|
-
import { siteData as siteDataRaw } from '@internal/siteData';
|
|
3
|
-
export const siteData = ref(readonly(siteDataRaw));
|
|
4
|
-
export const useSiteData = () => siteData;
|
|
5
|
-
if (import.meta.webpackHot || import.meta.hot) {
|
|
6
|
-
// reuse vue HMR runtime
|
|
7
|
-
__VUE_HMR_RUNTIME__.updateSiteData = (data) => {
|
|
8
|
-
siteData.value = readonly(data);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
import type { RouteLocale } from './routeLocale';
|
|
4
|
-
export declare type SiteLocaleData = SiteData;
|
|
5
|
-
export declare type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
|
|
6
|
-
export declare const siteLocaleDataSymbol: InjectionKey<SiteLocaleDataRef>;
|
|
7
|
-
export declare const useSiteLocaleData: () => SiteLocaleDataRef;
|
|
8
|
-
/**
|
|
9
|
-
* Merge the locales fields to the root fields
|
|
10
|
-
* according to the route path
|
|
11
|
-
*/
|
|
12
|
-
export declare const resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const siteLocaleDataSymbol = Symbol(__DEV__ ? 'siteLocaleData' : '');
|
|
3
|
-
export const useSiteLocaleData = () => {
|
|
4
|
-
const siteLocaleData = inject(siteLocaleDataSymbol);
|
|
5
|
-
if (!siteLocaleData) {
|
|
6
|
-
throw new Error('useSiteLocaleData() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return siteLocaleData;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Merge the locales fields to the root fields
|
|
12
|
-
* according to the route path
|
|
13
|
-
*/
|
|
14
|
-
export const resolveSiteLocaleData = (site, routeLocale) => ({
|
|
15
|
-
...site,
|
|
16
|
-
...site.locales[routeLocale],
|
|
17
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HeadConfig } from '@vuepress/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Query the matched head tag of head config
|
|
4
|
-
*/
|
|
5
|
-
export declare const queryHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
|
|
6
|
-
/**
|
|
7
|
-
* Create head tag from head config
|
|
8
|
-
*/
|
|
9
|
-
export declare const createHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
|
|
10
|
-
/**
|
|
11
|
-
* Auto update head
|
|
12
|
-
*
|
|
13
|
-
* This composable function should be used only once in the root app
|
|
14
|
-
*/
|
|
15
|
-
export declare const useUpdateHead: () => void;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, useSSRContext, watch } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
import { isPlainObject, isString } from '@vuepress/shared';
|
|
4
|
-
import { usePageHead } from './pageHead';
|
|
5
|
-
import { usePageLang } from './pageLang';
|
|
6
|
-
/**
|
|
7
|
-
* Query the matched head tag of head config
|
|
8
|
-
*/
|
|
9
|
-
export const queryHeadTag = ([tagName, attrs, content = '',]) => {
|
|
10
|
-
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
11
|
-
if (isString(value)) {
|
|
12
|
-
return `[${key}="${value}"]`;
|
|
13
|
-
}
|
|
14
|
-
if (value === true) {
|
|
15
|
-
return `[${key}]`;
|
|
16
|
-
}
|
|
17
|
-
return '';
|
|
18
|
-
});
|
|
19
|
-
const selector = `head > ${tagName}${attrsSelector}`;
|
|
20
|
-
const tags = Array.from(document.querySelectorAll(selector));
|
|
21
|
-
const matchedTag = tags.find((item) => item.innerText === content);
|
|
22
|
-
return matchedTag || null;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Create head tag from head config
|
|
26
|
-
*/
|
|
27
|
-
export const createHeadTag = ([tagName, attrs, content,]) => {
|
|
28
|
-
if (!isString(tagName)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
// create element
|
|
32
|
-
const tag = document.createElement(tagName);
|
|
33
|
-
// set attributes
|
|
34
|
-
if (isPlainObject(attrs)) {
|
|
35
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
36
|
-
if (isString(value)) {
|
|
37
|
-
tag.setAttribute(key, value);
|
|
38
|
-
}
|
|
39
|
-
else if (value === true) {
|
|
40
|
-
tag.setAttribute(key, '');
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// set content
|
|
45
|
-
if (isString(content)) {
|
|
46
|
-
tag.appendChild(document.createTextNode(content));
|
|
47
|
-
}
|
|
48
|
-
return tag;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Auto update head
|
|
52
|
-
*
|
|
53
|
-
* This composable function should be used only once in the root app
|
|
54
|
-
*/
|
|
55
|
-
export const useUpdateHead = () => {
|
|
56
|
-
const route = useRoute();
|
|
57
|
-
const head = usePageHead();
|
|
58
|
-
const lang = usePageLang();
|
|
59
|
-
// ssr-only, extract page meta info to ssrContext
|
|
60
|
-
if (__SSR__) {
|
|
61
|
-
const ssrContext = useSSRContext();
|
|
62
|
-
if (ssrContext) {
|
|
63
|
-
ssrContext.head = head.value;
|
|
64
|
-
ssrContext.lang = lang.value;
|
|
65
|
-
}
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const headTags = ref([]);
|
|
69
|
-
// load current head tags from DOM
|
|
70
|
-
const loadHead = () => {
|
|
71
|
-
head.value.forEach((item) => {
|
|
72
|
-
const tag = queryHeadTag(item);
|
|
73
|
-
if (tag) {
|
|
74
|
-
headTags.value.push(tag);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
// update html lang attribute and head tags to DOM
|
|
79
|
-
const updateHead = () => {
|
|
80
|
-
document.documentElement.lang = lang.value;
|
|
81
|
-
headTags.value.forEach((item) => {
|
|
82
|
-
if (item.parentNode === document.head) {
|
|
83
|
-
document.head.removeChild(item);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
headTags.value.splice(0, headTags.value.length);
|
|
87
|
-
head.value.forEach((item) => {
|
|
88
|
-
const tag = createHeadTag(item);
|
|
89
|
-
if (tag !== null) {
|
|
90
|
-
document.head.appendChild(tag);
|
|
91
|
-
headTags.value.push(tag);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
onMounted(() => {
|
|
96
|
-
loadHead();
|
|
97
|
-
updateHead();
|
|
98
|
-
watch(() => route.path, () => updateHead());
|
|
99
|
-
});
|
|
100
|
-
};
|
package/lib/server.d.ts
DELETED
package/lib/server.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createSSRApp } from 'vue';
|
|
2
|
-
import { createMemoryHistory } from 'vue-router';
|
|
3
|
-
import { createVueApp } from './app';
|
|
4
|
-
/**
|
|
5
|
-
* Server entry point, used for SSR
|
|
6
|
-
*/
|
|
7
|
-
export const createServerApp = async () => createVueApp({
|
|
8
|
-
appCreator: createSSRApp,
|
|
9
|
-
historyCreator: createMemoryHistory,
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type ClientAppSetup = () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/types/index.d.ts
DELETED
package/lib/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineClientAppEnhance = (clientAppEnhance) => clientAppEnhance;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineClientAppSetup = (clientAppSetup) => clientAppSetup;
|
package/lib/utils/index.d.ts
DELETED
package/lib/utils/index.js
DELETED
package/lib/utils/withBase.d.ts
DELETED
package/lib/utils/withBase.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isLinkHttp } from '@vuepress/shared';
|
|
2
|
-
import { useSiteData } from '../injections';
|
|
3
|
-
/**
|
|
4
|
-
* Prefix url with site base
|
|
5
|
-
*/
|
|
6
|
-
export const withBase = (url) => {
|
|
7
|
-
if (isLinkHttp(url))
|
|
8
|
-
return url;
|
|
9
|
-
const base = useSiteData().value.base;
|
|
10
|
-
return `${base}${url}`.replace(/\/+/, '/');
|
|
11
|
-
};
|
package/templates/index.dev.html
DELETED
package/templates/index.ssr.html
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="{{ lang }}">
|
|
3
|
-
<head>
|
|
4
|
-
<!--vuepress-ssr-head-->
|
|
5
|
-
<!--vuepress-ssr-resources-->
|
|
6
|
-
<!--vuepress-ssr-styles-->
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"><!--vuepress-ssr-app--></div>
|
|
10
|
-
<!--vuepress-ssr-scripts-->
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|