@vuepress/plugin-redirect 2.0.0-rc.41 → 2.0.0-rc.43

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 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
- return cli.outputHelp();
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(() => cli.outputHelp());
73
+ cli.command('').action(() => {
74
+ cli.outputHelp();
75
+ });
72
76
  cli.help();
73
77
  cli.version(version);
74
78
  cli.parse();
@@ -1,4 +1,4 @@
1
1
  import type { VNode } from 'vue';
2
2
  import '../styles/redirect-modal.css';
3
- declare const _default: import("vue").DefineComponent<{}, () => VNode | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
3
+ declare const _default: import("vue").DefineComponent<{}, () => VNode | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
4
4
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { usePreferredLanguages, useScrollLock, useSessionStorage, } from '@vueuse/core';
2
- import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, TransitionGroup, watch, } from 'vue';
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-labels
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-color);
34
- box-shadow: 0 2px 6px 0 var(--card-shadow);
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-bg-color-lighter);
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-bg-color-light);
49
+ background-color: var(--redirect-c-control-hover);
50
50
  }
51
51
  .redirect-modal-action.primary {
52
- background-color: var(--redirect-primary-color);
53
- color: var(--redirect-primary-text-color);
52
+ background-color: var(--redirect-c-accent-bg);
53
+ color: var(--redirect-c-accent-text);
54
54
  }
55
55
  .redirect-modal-action.primary:hover {
56
- background-color: var(--redirect-primary-hover-color);
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-color: #fff;
4
- --redirect-bg-color-light: #f3f4f5;
5
- --redirect-bg-color-lighter: #eee;
6
- --redirect-text-color: #2c3e50;
7
- --redirect-primary-color: #3eaf7c;
8
- --redirect-primary-hover-color: #4abf8a;
9
- --redirect-primary-text-color: #fff;
3
+ --redirect-c-bg: var(--vp-c-bg-elv);
4
+ --redirect-c-text: var(--vp-c-text);
5
+ --redirect-c-accent-bg: var(--vp-c-accent-bg);
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 }) => 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 = path
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 { logger, PLUGIN_NAME } from './logger.js';
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, app) => {
28
+ extendsBundlerOptions: (bundlerOptions) => {
29
29
  addViteSsrNoExternal(bundlerOptions, app, '@vuepress/helper');
30
30
  },
31
- extendsPage: (page, app) => {
31
+ extendsPage: (page) => {
32
32
  handleRedirectTo(page, app);
33
33
  },
34
- onInitialized: async (app) => {
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 (app) => {
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 (app) => {
46
+ onGenerated: async () => {
47
47
  await generateRedirectFiles(app, redirectMap);
48
48
  if (redirectLocaleConfig.autoLocale)
49
49
  await generateAutoLocaleRedirectFiles(app, redirectLocaleConfig);
@@ -1,4 +1,4 @@
1
1
  export interface RedirectPluginFrontmatterOption {
2
- redirectFrom?: string | string[];
2
+ redirectFrom?: string[] | string;
3
3
  redirectTo?: string;
4
4
  }
@@ -12,7 +12,7 @@ export interface RedirectPluginOptions extends Partial<Omit<RedirectLocaleConfig
12
12
  *
13
13
  * 多语言语言配置
14
14
  */
15
- localeConfig?: Record<string, string | string[]>;
15
+ localeConfig?: Record<string, string[] | string>;
16
16
  /**
17
17
  * Locales config
18
18
  *
@@ -40,7 +40,7 @@ export interface RedirectLocaleConfig {
40
40
  *
41
41
  * @default "defaultLocale"
42
42
  */
43
- defaultBehavior: 'defaultLocale' | 'homepage' | '404';
43
+ defaultBehavior: '404' | 'defaultLocale' | 'homepage';
44
44
  /**
45
45
  * Default locale path
46
46
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-redirect",
3
- "version": "2.0.0-rc.41",
3
+ "version": "2.0.0-rc.43",
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",
41
- "@vueuse/core": "^10.11.1",
40
+ "@vuepress/helper": "2.0.0-rc.43",
41
+ "@vueuse/core": "^11.0.3",
42
42
  "cac": "^6.7.14",
43
- "vue": "^3.4.37"
43
+ "vue": "^3.5.4"
44
44
  },
45
45
  "peerDependencies": {
46
- "vuepress": "2.0.0-rc.14"
46
+ "vuepress": "2.0.0-rc.15"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "7382aceb24df0b09f36ddd603dd4a00597343651"
51
+ "gitHead": "7c75a58f6aed788e2ee40e2b2f0451a76ec20a23"
52
52
  }