@vuepress/plugin-redirect 2.0.0-rc.10 → 2.0.0-rc.11

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.
@@ -1,3 +1,4 @@
1
1
  import type { ClientConfig } from 'vuepress/client';
2
+ import './styles/vars.css';
2
3
  declare const _default: ClientConfig;
3
4
  export default _default;
@@ -1,6 +1,7 @@
1
1
  import { defineClientConfig } from 'vuepress/client';
2
2
  import LanguageSwitch from './components/LanguageSwitch.js';
3
3
  import { setupDevServerRedirect } from './composables/setupDevServerRedirect.js';
4
+ import './styles/vars.css';
4
5
  export default defineClientConfig({
5
6
  setup() {
6
7
  if (__VUEPRESS_DEV__)
@@ -11,7 +11,7 @@
11
11
  .lang-modal-mask {
12
12
  position: fixed;
13
13
  inset: 0;
14
- z-index: 1499;
14
+ z-index: var(--redirect-z-index);
15
15
  display: flex;
16
16
  align-items: center;
17
17
  justify-content: center;
@@ -30,7 +30,7 @@
30
30
  max-width: 80vw;
31
31
  padding: 1rem 2rem;
32
32
  border-radius: 8px;
33
- background: var(--vp-bg);
33
+ background: var(--redirect-bg-color);
34
34
  box-shadow: 0 2px 6px 0 var(--card-shadow);
35
35
  }
36
36
 
@@ -41,17 +41,17 @@
41
41
  padding: 0.5rem 0.75rem;
42
42
  border: none;
43
43
  border-radius: 8px;
44
- background-color: var(--vp-bglt);
45
- color: var(--vp-c);
44
+ background-color: var(--redirect-bg-color-lighter);
45
+ color: inherit;
46
46
  cursor: pointer;
47
47
  }
48
48
  .lang-modal-action:hover {
49
- background-color: var(--vp-bgl);
49
+ background-color: var(--redirect-bg-color-light);
50
50
  }
51
51
  .lang-modal-action.primary {
52
- background-color: var(--vp-tc);
53
- color: var(--white);
52
+ background-color: var(--redirect-primary-color);
53
+ color: var(--redirect-primary-text-color);
54
54
  }
55
55
  .lang-modal-action.primary:hover {
56
- background-color: var(--vp-tcl);
56
+ background-color: var(--redirect-primary-hover-color);
57
57
  }
@@ -0,0 +1,10 @@
1
+ :root {
2
+ --redirect-z-index: 1499;
3
+ --redirect-bg-color: #fff;
4
+ --redirect-bg-color-light: #f3f4f5;
5
+ --redirect-bg-color-lighter: #eeeeee;
6
+ --redirect-text-color: #2c3e50;
7
+ --redirect-primary-bg-color: #3eaf7c;
8
+ --redirect-primary-hover-bg-color: #4abf8a;
9
+ --redirect-primary-text-color: #fff;
10
+ }
@@ -1,3 +1,2 @@
1
1
  import type { App } from 'vuepress/core';
2
- import type { RedirectLocaleConfig } from '../shared/index.js';
3
- export declare const ensureRootHomePage: (app: App, localeOptions: RedirectLocaleConfig) => Promise<void>;
2
+ export declare const ensureRootHomePage: (app: App) => Promise<void>;
@@ -1,67 +1,14 @@
1
- import { removeEndingSlash } from '@vuepress/helper';
2
1
  import { createPage } from 'vuepress/core';
3
- export const ensureRootHomePage = async (app, localeOptions) => {
4
- const { options: { base }, pages, } = app;
2
+ export const ensureRootHomePage = async (app) => {
5
3
  if (
6
4
  // root homepage not exists
7
- pages.every(({ path }) => path !== '/')) {
8
- const availableLocales = pages
9
- .filter(({ pathLocale, path }) => pathLocale === path)
10
- .map(({ pathLocale }) => pathLocale);
11
- pages.push(await createPage(app, {
5
+ app.pages.every(({ path }) => path !== '/')) {
6
+ app.pages.push(await createPage(app, {
12
7
  path: '/',
13
8
  frontmatter: { title: 'Home' },
14
9
  // set markdown content
15
10
  content: `\
16
11
  Redirecting to the correct locale...
17
-
18
- <script setup>
19
- import { onMounted } from "vue";
20
-
21
- if(!__VUEPRESS_DEV__)
22
- onMounted(() => {
23
- const { languages } = window.navigator;
24
- const { hash, origin } = window.location;
25
- const anchor = hash.substring(1);
26
-
27
- const localeConfig = ${JSON.stringify(localeOptions.localeConfig)};
28
- const availableLocales = ${JSON.stringify(availableLocales)};
29
- const defaultLocale = availableLocales.pop();
30
-
31
- let matchedLocalePath = null;
32
-
33
- // get matched locale
34
- findLanguage:
35
- for (const lang of languages)
36
- for (const [localePath, langs] of Object.entries(localeConfig))
37
- if (langs.includes(lang)) {
38
- ${localeOptions.localeFallback
39
- ? `\
40
- if (!availableLocales.includes(localePath))
41
- continue;
42
- `
43
- : ``}\
44
- matchedLocalePath = localePath;
45
- break findLanguage;
46
- }
47
-
48
- // default link
49
- const defaultLink = defaultLocale? \`\${origin}${removeEndingSlash(base)}\${defaultLocale}\${anchor? \`#\${anchor}\`: ""}\`: null;
50
-
51
- // a locale homepage exists
52
- if (matchedLocalePath && availableLocales.includes(matchedLocalePath)) {
53
- location.href = \`\${origin}${removeEndingSlash(base)}\${matchedLocalePath}\${anchor? \`#\${anchor}\`: ""}\`;
54
- }
55
- // we have a default page
56
- else if (defaultLink) {
57
- location.href = defaultLink;
58
- }
59
- // no homepage? WTF, just go to 404
60
- else {
61
- location.href = \`\${origin}${removeEndingSlash(base)}/404.html\`;
62
- }
63
- })
64
- </script>
65
12
  `,
66
13
  }));
67
14
  }
@@ -1,5 +1,5 @@
1
1
  import { removeEndingSlash } from '@vuepress/helper';
2
- export const getLocaleRedirectHTML = ({ localeConfig, defaultBehavior, defaultLocale, localeFallback, }, availableLocales, base) => `<!DOCTYPE html>
2
+ export const getLocaleRedirectHTML = ({ localeConfig, defaultBehavior, defaultLocale, localeFallback, }, availableLocales, base) => `<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -1,4 +1,4 @@
1
- export const getRedirectHTML = (redirectUrl) => `<!DOCTYPE html>
1
+ export const getRedirectHTML = (redirectUrl) => `<!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
@@ -35,8 +35,8 @@ export const redirectPlugin = (options = {}) => (app) => {
35
35
  redirectMap = getRedirectMap(app, options);
36
36
  if (app.env.isDebug)
37
37
  logger.info('Redirect Map:', redirectMap);
38
- if (redirectLocaleConfig.autoLocale)
39
- await ensureRootHomePage(app, redirectLocaleConfig);
38
+ if (redirectLocaleConfig.autoLocale && app.env.isDebug)
39
+ await ensureRootHomePage(app);
40
40
  },
41
41
  onPrepared: async (app) => {
42
42
  await app.writeTemp('redirect/map.js', `\
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-redirect",
3
- "version": "2.0.0-rc.10",
3
+ "version": "2.0.0-rc.11",
4
4
  "description": "VuePress plugin - redirect",
5
5
  "keywords": [
6
6
  "vuepress-plugin",
@@ -42,17 +42,17 @@
42
42
  "style": "sass src:lib --no-source-map"
43
43
  },
44
44
  "dependencies": {
45
- "@vuepress/helper": "~2.0.0-rc.10",
45
+ "@vuepress/helper": "~2.0.0-rc.11",
46
46
  "@vueuse/core": "^10.7.2",
47
47
  "cac": "^6.7.14",
48
48
  "vue": "^3.4.15",
49
49
  "vue-router": "^4.2.5"
50
50
  },
51
51
  "peerDependencies": {
52
- "vuepress": "2.0.0-rc.5"
52
+ "vuepress": "2.0.0-rc.6"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "2e4d75617b030b584fb59346087790c982dbf411"
57
+ "gitHead": "7ba11252716b7f900ecb4215b8a523c51d751738"
58
58
  }