@vuepress/theme-default 2.0.0-beta.27 → 2.0.0-beta.28

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,7 +1,9 @@
1
1
  <template>
2
2
  <main class="home" :aria-labelledby="heroText ? 'main-title' : undefined">
3
3
  <header class="hero">
4
- <img v-if="heroImage" :src="heroImage" :alt="heroAlt" />
4
+ <ClientOnly>
5
+ <img v-if="heroImage" :src="withBase(heroImage)" :alt="heroAlt" />
6
+ </ClientOnly>
5
7
 
6
8
  <h1 v-if="heroText" id="main-title">
7
9
  {{ heroText }}
@@ -50,18 +52,19 @@ import {
50
52
  import { isArray } from '@vuepress/shared'
51
53
  import { computed } from 'vue'
52
54
  import type { DefaultThemeHomePageFrontmatter } from '../../shared'
55
+ import { useDarkMode } from '../composables'
53
56
  import NavLink from './NavLink.vue'
54
57
 
55
58
  const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
56
59
  const siteLocale = useSiteLocaleData()
60
+ const isDarkMode = useDarkMode()
57
61
 
58
62
  // hero image and title
59
63
  const heroImage = computed(() => {
60
- if (!frontmatter.value.heroImage) {
61
- return null
64
+ if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined) {
65
+ return frontmatter.value.heroImageDark
62
66
  }
63
-
64
- return withBase(frontmatter.value.heroImage)
67
+ return frontmatter.value.heroImage
65
68
  })
66
69
  const heroText = computed(() => {
67
70
  if (frontmatter.value.heroText === null) {
@@ -58,12 +58,12 @@ const { item } = toRefs(props)
58
58
  // if the link has http protocol
59
59
  const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
60
60
  // if the link has non-http protocol
61
- const hasNonHttpProtocal = computed(
61
+ const hasNonHttpProtocol = computed(
62
62
  () => isLinkMailto(item.value.link) || isLinkTel(item.value.link)
63
63
  )
64
64
  // resolve the `target` attr
65
65
  const linkTarget = computed(() => {
66
- if (hasNonHttpProtocal.value) return undefined
66
+ if (hasNonHttpProtocol.value) return undefined
67
67
  if (item.value.target) return item.value.target
68
68
  if (hasHttpProtocol.value) return '_blank'
69
69
  return undefined
@@ -73,11 +73,11 @@ const isBlankTarget = computed(() => linkTarget.value === '_blank')
73
73
  // is `<RouterLink>` or not
74
74
  const isRouterLink = computed(
75
75
  () =>
76
- !hasHttpProtocol.value && !hasNonHttpProtocal.value && !isBlankTarget.value
76
+ !hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value
77
77
  )
78
78
  // resolve the `rel` attr
79
79
  const linkRel = computed(() => {
80
- if (hasNonHttpProtocal.value) return undefined
80
+ if (hasNonHttpProtocol.value) return undefined
81
81
  if (item.value.rel) return item.value.rel
82
82
  if (isBlankTarget.value) return 'noopener noreferrer'
83
83
  return undefined
@@ -6,7 +6,9 @@
6
6
 
7
7
  <div v-if="lastUpdated" class="meta-item last-updated">
8
8
  <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
9
- <span class="meta-item-info">{{ lastUpdated }}</span>
9
+ <ClientOnly>
10
+ <span class="meta-item-info">{{ lastUpdated }}</span>
11
+ </ClientOnly>
10
12
  </div>
11
13
 
12
14
  <div
@@ -99,7 +101,7 @@ const useLastUpdated = (): ComputedRef<null | string> => {
99
101
 
100
102
  const updatedDate = new Date(page.value.git?.updatedTime)
101
103
 
102
- return updatedDate.toLocaleString(siteLocale.value.lang)
104
+ return updatedDate.toLocaleString()
103
105
  })
104
106
  }
105
107
 
@@ -2,13 +2,11 @@
2
2
  <nav v-if="prevNavLink || nextNavLink" class="page-nav">
3
3
  <p class="inner">
4
4
  <span v-if="prevNavLink" class="prev">
5
- ←
6
5
  <NavLink :item="prevNavLink" />
7
6
  </span>
8
7
 
9
8
  <span v-if="nextNavLink" class="next">
10
9
  <NavLink :item="nextNavLink" />
11
- →
12
10
  </span>
13
11
  </p>
14
12
  </nav>
@@ -32,6 +32,7 @@ p a code {
32
32
 
33
33
  kbd {
34
34
  font-family: var(--font-family-code);
35
+ color: var(--c-text);
35
36
  background: var(--c-bg-lighter);
36
37
  border: solid 0.15rem var(--c-border-dark);
37
38
  border-bottom: solid 0.25rem var(--c-border-dark);
@@ -64,7 +64,15 @@
64
64
  overflow: auto;
65
65
  }
66
66
 
67
+ .prev {
68
+ a &:before {
69
+ content: '←';
70
+ }
71
+ }
67
72
  .next {
68
73
  float: right;
74
+ a &:after {
75
+ content: '→';
76
+ }
69
77
  }
70
78
  }
@@ -4,6 +4,6 @@ export declare const resolveEditLink: ({ docsRepo, docsBranch, docsDir, filePath
4
4
  docsRepo: string;
5
5
  docsBranch: string;
6
6
  docsDir: string;
7
- filePathRelative: string;
7
+ filePathRelative: string | null;
8
8
  editLinkPattern?: string | undefined;
9
9
  }) => string | null;
@@ -6,15 +6,20 @@ export const editLinkPatterns = {
6
6
  Gitee: ':repo/edit/:branch/:path',
7
7
  Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
8
8
  };
9
- export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
10
- const repoType = resolveRepoType(docsRepo);
11
- let pattern;
9
+ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
12
10
  if (editLinkPattern) {
13
- pattern = editLinkPattern;
11
+ return editLinkPattern;
14
12
  }
15
- else if (repoType !== null) {
16
- pattern = editLinkPatterns[repoType];
13
+ const repoType = resolveRepoType(docsRepo);
14
+ if (repoType !== null) {
15
+ return editLinkPatterns[repoType];
17
16
  }
17
+ return null;
18
+ };
19
+ export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
20
+ if (!filePathRelative)
21
+ return null;
22
+ const pattern = resolveEditLinkPatterns({ docsRepo, editLinkPattern });
18
23
  if (!pattern)
19
24
  return null;
20
25
  return pattern
@@ -3,15 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultTheme = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const utils_2 = require("./utils");
6
- const defaultTheme = ({ themePlugins = {}, ...localeOptions }) => {
6
+ const defaultTheme = ({ themePlugins = {}, ...localeOptions }, app) => {
7
+ if (app.options.bundler.endsWith('vite')) {
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
+ app.options.bundlerConfig.viteOptions = require('vite').mergeConfig(app.options.bundlerConfig.viteOptions, {
10
+ css: {
11
+ preprocessorOptions: {
12
+ scss: { charset: false },
13
+ },
14
+ },
15
+ });
16
+ }
7
17
  (0, utils_2.assignDefaultLocaleOptions)(localeOptions);
8
18
  return {
9
19
  name: '@vuepress/theme-default',
10
20
  layouts: utils_1.path.resolve(__dirname, '../client/layouts'),
11
21
  clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
12
22
  clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
13
- // use the relative file path to generate edit link
14
- extendsPageData: ({ filePathRelative }) => ({ filePathRelative }),
23
+ extendsPage: (page) => {
24
+ // save relative file path into page data to generate edit link
25
+ page.data.filePathRelative = page.filePathRelative;
26
+ // save title into route meta to generate navbar and sidebar
27
+ page.routeMeta.title = page.title;
28
+ },
15
29
  plugins: [
16
30
  [
17
31
  '@vuepress/active-header-links',
@@ -1,7 +1,7 @@
1
1
  import type { GitPluginPageData } from '@vuepress/plugin-git';
2
2
  import type { NavLink, SidebarConfig } from './nav';
3
3
  export interface DefaultThemePageData extends GitPluginPageData {
4
- filePathRelative: string;
4
+ filePathRelative: string | null;
5
5
  }
6
6
  export interface DefaultThemePageFrontmatter {
7
7
  home?: boolean;
@@ -11,6 +11,7 @@ export interface DefaultThemePageFrontmatter {
11
11
  export interface DefaultThemeHomePageFrontmatter extends DefaultThemePageFrontmatter {
12
12
  home: true;
13
13
  heroImage?: string;
14
+ heroImageDark?: string;
14
15
  heroAlt?: string;
15
16
  heroText?: string | null;
16
17
  tagline?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.27",
3
+ "version": "2.0.0-beta.28",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -29,27 +29,27 @@
29
29
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
30
30
  },
31
31
  "dependencies": {
32
- "@vuepress/client": "2.0.0-beta.27",
33
- "@vuepress/core": "2.0.0-beta.27",
34
- "@vuepress/plugin-active-header-links": "2.0.0-beta.27",
35
- "@vuepress/plugin-back-to-top": "2.0.0-beta.27",
36
- "@vuepress/plugin-container": "2.0.0-beta.27",
37
- "@vuepress/plugin-git": "2.0.0-beta.27",
38
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.27",
39
- "@vuepress/plugin-nprogress": "2.0.0-beta.27",
40
- "@vuepress/plugin-palette": "2.0.0-beta.27",
41
- "@vuepress/plugin-prismjs": "2.0.0-beta.27",
42
- "@vuepress/plugin-theme-data": "2.0.0-beta.27",
43
- "@vuepress/shared": "2.0.0-beta.27",
44
- "@vuepress/utils": "2.0.0-beta.27",
45
- "@vueuse/core": "^6.7.3",
46
- "sass": "^1.43.4",
47
- "sass-loader": "^12.2.0",
48
- "vue": "^3.2.20",
32
+ "@vuepress/client": "2.0.0-beta.28",
33
+ "@vuepress/core": "2.0.0-beta.28",
34
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.28",
35
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.28",
36
+ "@vuepress/plugin-container": "2.0.0-beta.28",
37
+ "@vuepress/plugin-git": "2.0.0-beta.28",
38
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.28",
39
+ "@vuepress/plugin-nprogress": "2.0.0-beta.28",
40
+ "@vuepress/plugin-palette": "2.0.0-beta.28",
41
+ "@vuepress/plugin-prismjs": "2.0.0-beta.28",
42
+ "@vuepress/plugin-theme-data": "2.0.0-beta.28",
43
+ "@vuepress/shared": "2.0.0-beta.28",
44
+ "@vuepress/utils": "2.0.0-beta.28",
45
+ "@vueuse/core": "^7.1.2",
46
+ "sass": "^1.44.0",
47
+ "sass-loader": "^12.4.0",
48
+ "vue": "^3.2.24",
49
49
  "vue-router": "^4.0.12"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "2671a94fe6864e215eb84f318b7e657744a0bc5d"
54
+ "gitHead": "71c34816a79263c7dcba3ff0c103e264abdbf0d2"
55
55
  }