@vuepress/theme-default 2.0.0-beta.50 → 2.0.0-beta.52

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.
@@ -22,6 +22,10 @@ const heroImage = computed(() => {
22
22
  }
23
23
  return frontmatter.value.heroImage
24
24
  })
25
+ const heroAlt = computed(
26
+ () => frontmatter.value.heroAlt || heroText.value || 'hero'
27
+ )
28
+ const heroHeight = computed(() => frontmatter.value.heroHeight || 280)
25
29
 
26
30
  const heroText = computed(() => {
27
31
  if (frontmatter.value.heroText === null) {
@@ -30,10 +34,6 @@ const heroText = computed(() => {
30
34
  return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
31
35
  })
32
36
 
33
- const heroAlt = computed(
34
- () => frontmatter.value.heroAlt || heroText.value || 'hero'
35
- )
36
-
37
37
  const tagline = computed(() => {
38
38
  if (frontmatter.value.tagline === null) {
39
39
  return null
@@ -62,6 +62,7 @@ const HomeHeroImage: FunctionalComponent = () => {
62
62
  const img = h('img', {
63
63
  src: withBase(heroImage.value),
64
64
  alt: heroAlt.value,
65
+ height: heroHeight.value,
65
66
  })
66
67
  if (frontmatter.value.heroImageDark === undefined) {
67
68
  return img
@@ -32,7 +32,7 @@ onMounted(() => {
32
32
  getCssValue(navbar.value, 'paddingLeft') +
33
33
  getCssValue(navbar.value, 'paddingRight')
34
34
  const handleLinksWrapWidth = (): void => {
35
- if (window.innerWidth <= MOBILE_DESKTOP_BREAKPOINT) {
35
+ if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
36
36
  linksWrapperMaxWidth.value = 0
37
37
  } else {
38
38
  linksWrapperMaxWidth.value =
@@ -3,7 +3,7 @@ import AutoLink from '@theme/AutoLink.vue'
3
3
  import NavbarDropdown from '@theme/NavbarDropdown.vue'
4
4
  import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
5
5
  import { isLinkHttp, isString } from '@vuepress/shared'
6
- import { computed } from 'vue'
6
+ import { computed, onMounted, ref } from 'vue'
7
7
  import type { ComputedRef } from 'vue'
8
8
  import { useRouter } from 'vue-router'
9
9
  import type {
@@ -143,6 +143,7 @@ const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
143
143
  return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
144
144
  }
145
145
 
146
+ const isMobile = ref(false)
146
147
  const navbarConfig = useNavbarConfig()
147
148
  const navbarSelectLanguage = useNavbarSelectLanguage()
148
149
  const navbarRepo = useNavbarRepo()
@@ -151,12 +152,34 @@ const navbarLinks = computed(() => [
151
152
  ...navbarSelectLanguage.value,
152
153
  ...navbarRepo.value,
153
154
  ])
155
+
156
+ // avoid overlapping of long title and long navbar links
157
+ onMounted(() => {
158
+ // TODO: migrate to css var
159
+ // refer to _variables.scss
160
+ const MOBILE_DESKTOP_BREAKPOINT = 719
161
+
162
+ const handleMobile = (): void => {
163
+ if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
164
+ isMobile.value = true
165
+ } else {
166
+ isMobile.value = false
167
+ }
168
+ }
169
+ handleMobile()
170
+ window.addEventListener('resize', handleMobile, false)
171
+ window.addEventListener('orientationchange', handleMobile, false)
172
+ })
154
173
  </script>
155
174
 
156
175
  <template>
157
176
  <nav v-if="navbarLinks.length" class="navbar-items">
158
177
  <div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
159
- <NavbarDropdown v-if="item.children" :item="item" />
178
+ <NavbarDropdown
179
+ v-if="item.children"
180
+ :item="item"
181
+ :class="isMobile ? 'mobile' : ''"
182
+ />
160
183
  <AutoLink v-else :item="item" />
161
184
  </div>
162
185
  </nav>
@@ -1,4 +1,4 @@
1
1
  import type { VNode } from 'vue';
2
2
  export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
3
  [key: string]: any;
4
- }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
4
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
@@ -53,7 +53,7 @@ export const resolveSidebarItems = (frontmatter, themeLocale) => {
53
53
  */
54
54
  export const headerToSidebarItem = (header, sidebarDepth) => ({
55
55
  text: header.title,
56
- link: `#${header.slug}`,
56
+ link: header.link,
57
57
  children: headersToSidebarItemChildren(header.children, sidebarDepth),
58
58
  });
59
59
  export const headersToSidebarItemChildren = (headers, sidebarDepth) => sidebarDepth > 0
@@ -2,6 +2,8 @@ import { defineClientConfig } from '@vuepress/client';
2
2
  import { h } from 'vue';
3
3
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
4
4
  import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
5
+ import Layout from './layouts/Layout.vue';
6
+ import NotFound from './layouts/NotFound.vue';
5
7
  import './styles/index.scss';
6
8
  export default defineClientConfig({
7
9
  enhance({ app, router }) {
@@ -35,4 +37,8 @@ export default defineClientConfig({
35
37
  setupDarkMode();
36
38
  setupSidebarItems();
37
39
  },
40
+ layouts: {
41
+ Layout,
42
+ NotFound,
43
+ },
38
44
  });
File without changes
@@ -4,8 +4,3 @@
4
4
  $MQNarrow: 959px !default;
5
5
  $MQMobile: 719px !default;
6
6
  $MQMobileNarrow: 419px !default;
7
-
8
- // code languages
9
- $codeLang: 'c' 'cpp' 'cs' 'css' 'dart' 'docker' 'fs' 'go' 'html' 'java' 'js'
10
- 'json' 'kt' 'less' 'makefile' 'md' 'php' 'py' 'rb' 'rs' 'sass' 'scss' 'sh'
11
- 'styl' 'ts' 'toml' 'vue' 'yml' !default;
@@ -152,6 +152,7 @@ div[class*='language-'] {
152
152
  border-radius: 6px;
153
153
 
154
154
  &::before {
155
+ content: attr(data-ext);
155
156
  position: absolute;
156
157
  z-index: 3;
157
158
  top: 0.8em;
@@ -247,14 +248,6 @@ div[class*='language-'] {
247
248
  }
248
249
  }
249
250
 
250
- @each $lang in $codeLang {
251
- div[class*='language-'].ext-#{$lang} {
252
- &:before {
253
- content: '' + $lang;
254
- }
255
- }
256
- }
257
-
258
251
  // narrow mobile
259
252
  @media (max-width: $MQMobileNarrow) {
260
253
  .theme-default-content {
@@ -107,16 +107,17 @@
107
107
  }
108
108
  }
109
109
  }
110
+ .theme-container.no-sidebar {
111
+ .sidebar {
112
+ display: none;
110
113
 
111
- @media (min-width: ($MQMobile + 1px)) {
112
- .theme-container.no-sidebar {
113
- .sidebar {
114
- display: none;
114
+ @media (max-width: $MQMobile) {
115
+ display: block;
115
116
  }
117
+ }
116
118
 
117
- .page {
118
- padding-left: 0;
119
- }
119
+ .page {
120
+ padding-left: 0;
120
121
  }
121
122
  }
122
123
 
@@ -108,10 +108,8 @@
108
108
  }
109
109
  }
110
110
  }
111
- }
112
111
 
113
- @media (max-width: $MQMobile) {
114
- .navbar-dropdown-wrapper {
112
+ &.mobile {
115
113
  &.open .navbar-dropdown-title {
116
114
  margin-bottom: 0.5rem;
117
115
  }
@@ -148,10 +146,8 @@
148
146
  }
149
147
  }
150
148
  }
151
- }
152
149
 
153
- @media (min-width: ($MQMobile + 1)) {
154
- .navbar-dropdown-wrapper {
150
+ &:not(.mobile) {
155
151
  height: 1.8rem;
156
152
 
157
153
  &:hover .navbar-dropdown,
@@ -69,7 +69,7 @@
69
69
 
70
70
  &:hover,
71
71
  &.router-link-active {
72
- color: var(--c-text-accent);
72
+ color: var(--c-text);
73
73
  }
74
74
  }
75
75
 
@@ -82,6 +82,14 @@
82
82
  &:first-child {
83
83
  margin-left: 0;
84
84
  }
85
+
86
+ > a {
87
+ &:hover,
88
+ &.router-link-active {
89
+ margin-bottom: -2px;
90
+ border-bottom: 2px solid var(--c-text-accent);
91
+ }
92
+ }
85
93
  }
86
94
  }
87
95
 
@@ -89,23 +97,21 @@
89
97
  .navbar-items {
90
98
  .navbar-item {
91
99
  margin-left: 0;
92
- }
93
- }
94
- }
95
100
 
96
- @media (min-width: $MQMobile) {
97
- .navbar-items a {
98
- &:hover,
99
- &.router-link-active {
100
- color: var(--c-text);
101
+ > a {
102
+ &:hover,
103
+ &.router-link-active {
104
+ margin-bottom: 0;
105
+ border-bottom: none;
106
+ }
107
+ }
101
108
  }
102
- }
103
109
 
104
- .navbar-item > a {
105
- &:hover,
106
- &.router-link-active {
107
- margin-bottom: -2px;
108
- border-bottom: 2px solid var(--c-text-accent);
110
+ a {
111
+ &:hover,
112
+ &.router-link-active {
113
+ color: var(--c-text-accent);
114
+ }
109
115
  }
110
116
  }
111
117
  }
@@ -15,7 +15,6 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
15
15
  assignDefaultLocaleOptions(localeOptions);
16
16
  return {
17
17
  name: '@vuepress/theme-default',
18
- layouts: path.resolve(__dirname, '../client/layouts'),
19
18
  templateBuild: path.resolve(__dirname, '../../templates/build.html'),
20
19
  alias: {
21
20
  // use alias to make all components replaceable
@@ -26,8 +25,6 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
26
25
  `@theme/${file}`,
27
26
  path.resolve(__dirname, '../client/components', file),
28
27
  ])),
29
- // workaround for https://github.com/vitejs/vite/issues/7621
30
- '@vuepress/theme-default/client': path.resolve(__dirname, '../client/index.js'),
31
28
  },
32
29
  clientConfigFile: path.resolve(__dirname, '../client/config.js'),
33
30
  extendsPage: (page) => {
@@ -13,6 +13,7 @@ export interface DefaultThemeHomePageFrontmatter extends DefaultThemePageFrontma
13
13
  heroImage?: string;
14
14
  heroImageDark?: string;
15
15
  heroAlt?: string;
16
+ heroHeight?: number;
16
17
  heroText?: string | null;
17
18
  tagline?: string | null;
18
19
  actions?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.50",
3
+ "version": "2.0.0-beta.52",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -24,7 +24,9 @@
24
24
  "./client": "./lib/client/index.js",
25
25
  "./components/*": "./lib/client/components/*",
26
26
  "./layouts/*": "./lib/client/layouts/*",
27
+ "./styles/*": "./lib/client/styles/*",
27
28
  "./templates/*": "./templates/*",
29
+ "./lib/*": "./lib/*",
28
30
  "./package.json": "./package.json"
29
31
  },
30
32
  "main": "./lib/node/index.js",
@@ -34,27 +36,27 @@
34
36
  "templates"
35
37
  ],
36
38
  "dependencies": {
37
- "@vuepress/client": "2.0.0-beta.50",
38
- "@vuepress/core": "2.0.0-beta.50",
39
- "@vuepress/plugin-active-header-links": "2.0.0-beta.50",
40
- "@vuepress/plugin-back-to-top": "2.0.0-beta.50",
41
- "@vuepress/plugin-container": "2.0.0-beta.50",
42
- "@vuepress/plugin-external-link-icon": "2.0.0-beta.50",
43
- "@vuepress/plugin-git": "2.0.0-beta.50",
44
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.50",
45
- "@vuepress/plugin-nprogress": "2.0.0-beta.50",
46
- "@vuepress/plugin-palette": "2.0.0-beta.50",
47
- "@vuepress/plugin-prismjs": "2.0.0-beta.50",
48
- "@vuepress/plugin-theme-data": "2.0.0-beta.50",
49
- "@vuepress/shared": "2.0.0-beta.50",
50
- "@vuepress/utils": "2.0.0-beta.50",
51
- "@vueuse/core": "^9.1.0",
52
- "sass": "^1.54.5",
53
- "vue": "^3.2.37",
54
- "vue-router": "^4.1.4"
39
+ "@vuepress/client": "2.0.0-beta.52",
40
+ "@vuepress/core": "2.0.0-beta.52",
41
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.52",
42
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.52",
43
+ "@vuepress/plugin-container": "2.0.0-beta.52",
44
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.52",
45
+ "@vuepress/plugin-git": "2.0.0-beta.52",
46
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.52",
47
+ "@vuepress/plugin-nprogress": "2.0.0-beta.52",
48
+ "@vuepress/plugin-palette": "2.0.0-beta.52",
49
+ "@vuepress/plugin-prismjs": "2.0.0-beta.52",
50
+ "@vuepress/plugin-theme-data": "2.0.0-beta.52",
51
+ "@vuepress/shared": "2.0.0-beta.52",
52
+ "@vuepress/utils": "2.0.0-beta.52",
53
+ "@vueuse/core": "^9.3.1",
54
+ "sass": "^1.55.0",
55
+ "vue": "^3.2.41",
56
+ "vue-router": "^4.1.5"
55
57
  },
56
58
  "peerDependencies": {
57
- "sass-loader": "^13.0.0"
59
+ "sass-loader": "^13.0.2"
58
60
  },
59
61
  "peerDependenciesMeta": {
60
62
  "sass-loader": {
@@ -23,8 +23,8 @@
23
23
  }
24
24
  </script>
25
25
  <!--vuepress-ssr-head-->
26
- <!--vuepress-ssr-resources-->
27
26
  <!--vuepress-ssr-styles-->
27
+ <!--vuepress-ssr-resources-->
28
28
  </head>
29
29
  <body>
30
30
  <div id="app"><!--vuepress-ssr-app--></div>