@vuepress/plugin-redirect 2.0.0-rc.40 → 2.0.0-rc.42
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/lib/cli/index.js +7 -3
- package/lib/client/components/RedirectModal.js +1 -1
- package/lib/client/composables/setupDevServerRedirect.js +1 -2
- package/lib/client/styles/redirect-modal.css +7 -7
- package/lib/client/styles/vars.css +8 -7
- package/lib/node/generate/generateAutoLocaleRedirectFiles.js +3 -3
- package/lib/node/redirectPlugin.js +6 -6
- package/lib/node/types/frontmatter.d.ts +1 -1
- package/lib/node/types/options.d.ts +1 -1
- package/lib/shared/localeConfig.d.ts +1 -1
- package/package.json +6 -6
package/lib/cli/index.js
CHANGED
|
@@ -19,8 +19,10 @@ cli
|
|
|
19
19
|
.option('--clean-cache', 'Clean the cache files before generation')
|
|
20
20
|
.option('--clean-temp', 'Clean the temporary files before generation')
|
|
21
21
|
.action(async (sourceDir, commandOptions) => {
|
|
22
|
-
if (!sourceDir)
|
|
23
|
-
|
|
22
|
+
if (!sourceDir) {
|
|
23
|
+
cli.outputHelp();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
24
26
|
// ensure NODE_ENV is set
|
|
25
27
|
process.env.NODE_ENV ??= 'production';
|
|
26
28
|
// resolve app config from cli options
|
|
@@ -68,7 +70,9 @@ cli
|
|
|
68
70
|
.then(() => fs.writeFile(destLocation, getRedirectHTML(redirectUrl)));
|
|
69
71
|
}));
|
|
70
72
|
});
|
|
71
|
-
cli.command('').action(() =>
|
|
73
|
+
cli.command('').action(() => {
|
|
74
|
+
cli.outputHelp();
|
|
75
|
+
});
|
|
72
76
|
cli.help();
|
|
73
77
|
cli.version(version);
|
|
74
78
|
cli.parse();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { usePreferredLanguages, useScrollLock, useSessionStorage, } from '@vueuse/core';
|
|
2
|
-
import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref,
|
|
2
|
+
import { TransitionGroup, computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, watch, } from 'vue';
|
|
3
3
|
import { useRouteLocale, useRoutePath, useRouter } from 'vuepress/client';
|
|
4
4
|
import { redirectLocaleConfig, redirectLocaleEntries } from '../define.js';
|
|
5
5
|
import '../styles/redirect-modal.css';
|
|
@@ -21,7 +21,7 @@ export const setupDevServerRedirect = () => {
|
|
|
21
21
|
path === route.path.replace(/^\/[^/]+\//, '/'))?.path;
|
|
22
22
|
let matchedLocalePath = null;
|
|
23
23
|
// get matched locale
|
|
24
|
-
// eslint-disable-next-line no-
|
|
24
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
25
25
|
findLanguage: for (const lang of languages.value)
|
|
26
26
|
for (const [localePath, langs] of redirectLocaleEntries)
|
|
27
27
|
if (langs.includes(lang)) {
|
|
@@ -29,7 +29,6 @@ export const setupDevServerRedirect = () => {
|
|
|
29
29
|
routes.every(({ path }) => path !== route.path.replace('/', path)))
|
|
30
30
|
continue;
|
|
31
31
|
matchedLocalePath = localePath;
|
|
32
|
-
// eslint-disable-next-line no-labels
|
|
33
32
|
break findLanguage;
|
|
34
33
|
}
|
|
35
34
|
// default link
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
max-width: 80vw;
|
|
31
31
|
padding: 1rem 2rem;
|
|
32
32
|
border-radius: 8px;
|
|
33
|
-
background: var(--redirect-bg
|
|
34
|
-
box-shadow: 0 2px 6px 0 var(--
|
|
33
|
+
background: var(--redirect-c-bg);
|
|
34
|
+
box-shadow: 0 2px 6px 0 var(--redirect-c-shadow);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.redirect-modal-action {
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
padding: 0.5rem 0.75rem;
|
|
42
42
|
border: none;
|
|
43
43
|
border-radius: 8px;
|
|
44
|
-
background-color: var(--redirect-
|
|
44
|
+
background-color: var(--redirect-c-control);
|
|
45
45
|
color: inherit;
|
|
46
46
|
cursor: pointer;
|
|
47
47
|
}
|
|
48
48
|
.redirect-modal-action:hover {
|
|
49
|
-
background-color: var(--redirect-
|
|
49
|
+
background-color: var(--redirect-c-control-hover);
|
|
50
50
|
}
|
|
51
51
|
.redirect-modal-action.primary {
|
|
52
|
-
background-color: var(--redirect-
|
|
53
|
-
color: var(--redirect-
|
|
52
|
+
background-color: var(--redirect-c-accent);
|
|
53
|
+
color: var(--redirect-c-accent-text);
|
|
54
54
|
}
|
|
55
55
|
.redirect-modal-action.primary:hover {
|
|
56
|
-
background-color: var(--redirect-
|
|
56
|
+
background-color: var(--redirect-c-accent-hover);
|
|
57
57
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--redirect-z-index: 1499;
|
|
3
|
-
--redirect-bg
|
|
4
|
-
--redirect-
|
|
5
|
-
--redirect-
|
|
6
|
-
--redirect-
|
|
7
|
-
--redirect-
|
|
8
|
-
--redirect-
|
|
9
|
-
--redirect-
|
|
3
|
+
--redirect-c-bg: var(--vp-c-bg-elv);
|
|
4
|
+
--redirect-c-text: var(--vp-c-text);
|
|
5
|
+
--redirect-c-accent: var(--vp-c-accent);
|
|
6
|
+
--redirect-c-accent-hover: var(--vp-c-accent-hover);
|
|
7
|
+
--redirect-c-accent-text: var(--vp-c-accent-text);
|
|
8
|
+
--redirect-c-control: var(--vp-c-control);
|
|
9
|
+
--redirect-c-control-hover: var(--vp-c-control-hover);
|
|
10
|
+
--redirect-c-shadow: var(--vp-c-shadow);
|
|
10
11
|
}
|
|
@@ -5,12 +5,12 @@ import { getLocaleRedirectHTML } from './getLocaleRedirectHTML.js';
|
|
|
5
5
|
export const generateAutoLocaleRedirectFiles = async ({ dir, options, pages }, localeOptions) => {
|
|
6
6
|
const rootPaths = pages
|
|
7
7
|
.filter(({ pathLocale }) => pathLocale === '/')
|
|
8
|
-
.map(({ path }) =>
|
|
8
|
+
.map(({ path: pagePath }) => pagePath);
|
|
9
9
|
const localeRedirectMap = {};
|
|
10
10
|
pages
|
|
11
11
|
.filter(({ pathLocale }) => pathLocale !== '/')
|
|
12
|
-
.forEach(({ path, pathLocale }) => {
|
|
13
|
-
const rootPath =
|
|
12
|
+
.forEach(({ path: pagePath, pathLocale }) => {
|
|
13
|
+
const rootPath = pagePath
|
|
14
14
|
.replace(pathLocale, '/')
|
|
15
15
|
.replace(/\/$/, '/index.html');
|
|
16
16
|
if (!rootPaths.includes(rootPath))
|
|
@@ -6,7 +6,7 @@ import { getRedirectLocaleConfig } from './getRedirectLocaleConfig.js';
|
|
|
6
6
|
import { getRedirectMap } from './getRedirectMap.js';
|
|
7
7
|
import { handleRedirectTo } from './handleRedirectTo.js';
|
|
8
8
|
import { redirectLocales } from './locales.js';
|
|
9
|
-
import {
|
|
9
|
+
import { PLUGIN_NAME, logger } from './logger.js';
|
|
10
10
|
const __dirname = getDirname(import.meta.url);
|
|
11
11
|
export const redirectPlugin = (options = {}) => (app) => {
|
|
12
12
|
if (app.env.isDebug)
|
|
@@ -25,25 +25,25 @@ export const redirectPlugin = (options = {}) => (app) => {
|
|
|
25
25
|
default: redirectLocales,
|
|
26
26
|
}),
|
|
27
27
|
},
|
|
28
|
-
extendsBundlerOptions: (bundlerOptions
|
|
28
|
+
extendsBundlerOptions: (bundlerOptions) => {
|
|
29
29
|
addViteSsrNoExternal(bundlerOptions, app, '@vuepress/helper');
|
|
30
30
|
},
|
|
31
|
-
extendsPage: (page
|
|
31
|
+
extendsPage: (page) => {
|
|
32
32
|
handleRedirectTo(page, app);
|
|
33
33
|
},
|
|
34
|
-
onInitialized: async (
|
|
34
|
+
onInitialized: async () => {
|
|
35
35
|
redirectMap = getRedirectMap(app, options);
|
|
36
36
|
if (app.env.isDebug)
|
|
37
37
|
logger.info('Redirect Map:', redirectMap);
|
|
38
38
|
if (redirectLocaleConfig.autoLocale && app.env.isDebug)
|
|
39
39
|
await ensureRootHomePage(app);
|
|
40
40
|
},
|
|
41
|
-
onPrepared: async (
|
|
41
|
+
onPrepared: async () => {
|
|
42
42
|
await app.writeTemp('redirect/map.js', `\
|
|
43
43
|
export const redirectMap = ${app.env.isDev ? JSON.stringify(redirectMap, null, 2) : '{}'};
|
|
44
44
|
`);
|
|
45
45
|
},
|
|
46
|
-
onGenerated: async (
|
|
46
|
+
onGenerated: async () => {
|
|
47
47
|
await generateRedirectFiles(app, redirectMap);
|
|
48
48
|
if (redirectLocaleConfig.autoLocale)
|
|
49
49
|
await generateAutoLocaleRedirectFiles(app, redirectLocaleConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/plugin-redirect",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.42",
|
|
4
4
|
"description": "VuePress plugin - redirect",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-plugin",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"lib"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
41
|
-
"@vueuse/core": "^
|
|
40
|
+
"@vuepress/helper": "2.0.0-rc.42",
|
|
41
|
+
"@vueuse/core": "^11.0.1",
|
|
42
42
|
"cac": "^6.7.14",
|
|
43
|
-
"vue": "^3.4.
|
|
43
|
+
"vue": "^3.4.38"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vuepress": "2.0.0-rc.
|
|
46
|
+
"vuepress": "2.0.0-rc.15"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "66e494405a7fbb02f6d46d7be670ec69605b7606"
|
|
52
52
|
}
|