@vuepress/theme-default 2.0.0-rc.21 → 2.0.0-rc.23

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.
@@ -32,6 +32,16 @@ const linksWrapperStyle = computed(() => {
32
32
  }
33
33
  })
34
34
 
35
+ const getCssValue = (el: HTMLElement | null, property: string): number => {
36
+ // NOTE: Known bug, will return 'auto' if style value is 'auto'
37
+ const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
38
+ property
39
+ ]
40
+ const num = Number.parseInt(val, 10)
41
+
42
+ return Number.isNaN(num) ? 0 : num
43
+ }
44
+
35
45
  useUpdateDeviceStatus(
36
46
  DeviceType.MOBILE,
37
47
  (mobileDesktopBreakpoint: number): void => {
@@ -49,15 +59,6 @@ useUpdateDeviceStatus(
49
59
  }
50
60
  },
51
61
  )
52
-
53
- function getCssValue(el: HTMLElement | null, property: string): number {
54
- // NOTE: Known bug, will return 'auto' if style value is 'auto'
55
- const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
56
- property
57
- ]
58
- const num = Number.parseInt(val, 10)
59
- return Number.isNaN(num) ? 0 : num
60
- }
61
62
  </script>
62
63
 
63
64
  <template>
@@ -94,31 +94,128 @@ const contributors = useContributors()
94
94
  </script>
95
95
 
96
96
  <template>
97
- <footer class="page-meta">
98
- <div v-if="editNavLink" class="meta-item edit-link">
99
- <AutoLink class="meta-item-label" :item="editNavLink" />
100
- </div>
101
-
102
- <div v-if="lastUpdated" class="meta-item last-updated">
103
- <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
104
- <ClientOnly>
105
- <span class="meta-item-info">{{ lastUpdated }}</span>
106
- </ClientOnly>
97
+ <footer class="vp-page-meta">
98
+ <div v-if="editNavLink" class="vp-meta-item edit-link">
99
+ <AutoLink class="label" :item="editNavLink">
100
+ <template #before>
101
+ <svg class="icon" viewBox="0 0 1024 1024">
102
+ <g fill="currentColor">
103
+ <path
104
+ d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"
105
+ />
106
+ <path
107
+ d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"
108
+ />
109
+ </g>
110
+ </svg>
111
+ </template>
112
+ </AutoLink>
107
113
  </div>
108
114
 
109
- <div
110
- v-if="contributors && contributors.length"
111
- class="meta-item contributors"
112
- >
113
- <span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
114
- <span class="meta-item-info">
115
- <template v-for="(contributor, index) in contributors" :key="index">
116
- <span class="contributor" :title="`email: ${contributor.email}`">
117
- {{ contributor.name }}
118
- </span>
119
- <template v-if="index !== contributors.length - 1">, </template>
120
- </template>
121
- </span>
115
+ <div class="vp-meta-item git-info">
116
+ <div v-if="lastUpdated" class="vp-meta-item last-updated">
117
+ <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
118
+ <ClientOnly>
119
+ <span class="meta-item-info">{{ lastUpdated }}</span>
120
+ </ClientOnly>
121
+ </div>
122
+
123
+ <div
124
+ v-if="contributors && contributors.length"
125
+ class="vp-meta-item contributors"
126
+ >
127
+ <span class="meta-item-label"
128
+ >{{ themeLocale.contributorsText }}:
129
+ </span>
130
+ <span class="meta-item-info">
131
+ <template v-for="(contributor, index) in contributors" :key="index">
132
+ <span class="contributor" :title="`email: ${contributor.email}`">
133
+ {{ contributor.name }}
134
+ </span>
135
+ <template v-if="index !== contributors.length - 1">, </template>
136
+ </template>
137
+ </span>
138
+ </div>
122
139
  </div>
123
140
  </footer>
124
141
  </template>
142
+
143
+ <style lang="scss">
144
+ @use '../styles/mixins';
145
+ @import '../styles/_variables';
146
+
147
+ .vp-page-meta {
148
+ @include mixins.content_wrapper;
149
+
150
+ display: flex;
151
+ flex-wrap: wrap;
152
+ justify-content: space-between;
153
+
154
+ overflow: auto;
155
+
156
+ padding-top: 0.75rem;
157
+ padding-bottom: 0.75rem;
158
+
159
+ @media print {
160
+ margin: 0 !important;
161
+ padding-inline: 0 !important;
162
+ }
163
+
164
+ @media (max-width: $MQMobile) {
165
+ display: block;
166
+ }
167
+
168
+ .vp-meta-item {
169
+ flex-grow: 1;
170
+
171
+ .vp-meta-label {
172
+ font-weight: 500;
173
+
174
+ &:not(a) {
175
+ color: var(--c-text-lighter);
176
+ }
177
+ }
178
+
179
+ .vp-meta-info {
180
+ color: var(--c-text-quote);
181
+ font-weight: 400;
182
+ }
183
+ }
184
+
185
+ .git-info {
186
+ text-align: end;
187
+ }
188
+
189
+ .edit-link {
190
+ margin-top: 0.25rem;
191
+ margin-bottom: 0.25rem;
192
+ margin-inline-end: 0.5rem;
193
+ font-size: 14px;
194
+
195
+ @media print {
196
+ display: none;
197
+ }
198
+
199
+ .icon {
200
+ position: relative;
201
+ bottom: -0.125em;
202
+
203
+ width: 1em;
204
+ height: 1em;
205
+ margin-inline-end: 0.25em;
206
+ }
207
+ }
208
+
209
+ .last-updated,
210
+ .contributors {
211
+ margin-top: 0.25rem;
212
+ margin-bottom: 0.25rem;
213
+ font-size: 14px;
214
+
215
+ @media (max-width: $MQMobile) {
216
+ font-size: 13px;
217
+ text-align: start;
218
+ }
219
+ }
220
+ }
221
+ </style>
@@ -1,9 +1,9 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
+ import { resolveRoute } from '@vuepress/helper/client'
3
4
  import { useEventListener } from '@vueuse/core'
4
5
  import { computed } from 'vue'
5
- import type { Router } from 'vuepress/client'
6
- import { usePageFrontmatter, useRoute, useRouter } from 'vuepress/client'
6
+ import { usePageFrontmatter, useRoute } from 'vuepress/client'
7
7
  import { isPlainObject, isString } from 'vuepress/shared'
8
8
  import type {
9
9
  DefaultThemeNormalPageFrontmatter,
@@ -15,25 +15,36 @@ import {
15
15
  useSidebarItems,
16
16
  useThemeLocaleData,
17
17
  } from '../composables/index.js'
18
- import { getNavLink } from '../utils/index.js'
19
18
 
20
19
  /**
21
20
  * Resolve `prev` or `next` config from frontmatter
22
21
  */
23
22
  const resolveFromFrontmatterConfig = (
24
- router: Router,
25
23
  conf: unknown,
24
+ current: string,
26
25
  ): null | false | NavLink => {
27
26
  if (conf === false) {
28
27
  return null
29
28
  }
30
29
 
31
30
  if (isString(conf)) {
32
- return getNavLink(router, conf)
31
+ const { notFound, meta, path } = resolveRoute<{
32
+ title?: string
33
+ }>(conf, current)
34
+
35
+ return notFound
36
+ ? { text: path, link: path }
37
+ : {
38
+ text: meta.title || path,
39
+ link: path,
40
+ }
33
41
  }
34
42
 
35
43
  if (isPlainObject<NavLink>(conf)) {
36
- return conf
44
+ return {
45
+ ...conf,
46
+ link: resolveRoute(conf.link, current).path,
47
+ }
37
48
  }
38
49
 
39
50
  return false
@@ -76,13 +87,12 @@ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
76
87
  const sidebarItems = useSidebarItems()
77
88
  const themeLocale = useThemeLocaleData()
78
89
  const route = useRoute()
79
- const router = useRouter()
80
90
  const navigate = useNavigate()
81
91
 
82
92
  const prevNavLink = computed(() => {
83
93
  const prevConfig = resolveFromFrontmatterConfig(
84
- router,
85
94
  frontmatter.value.prev,
95
+ route.path,
86
96
  )
87
97
  if (prevConfig !== false) {
88
98
  return prevConfig
@@ -93,8 +103,8 @@ const prevNavLink = computed(() => {
93
103
 
94
104
  const nextNavLink = computed(() => {
95
105
  const nextConfig = resolveFromFrontmatterConfig(
96
- router,
97
106
  frontmatter.value.next,
107
+ route.path,
98
108
  )
99
109
  if (nextConfig !== false) {
100
110
  return nextConfig
@@ -153,7 +163,7 @@ useEventListener('keydown', (event): void => {
153
163
  </template>
154
164
 
155
165
  <style lang="scss">
156
- @import '../styles/_variables';
166
+ @import '../styles/variables';
157
167
 
158
168
  .vp-page-nav {
159
169
  display: flex;
@@ -1,3 +1,4 @@
1
+ import { useEventListener } from '@vueuse/core';
1
2
  import { onMounted } from 'vue';
2
3
  import cssVars from '../styles/_variables.module.scss?module';
3
4
  export var DeviceType;
@@ -17,9 +18,9 @@ export const useUpdateDeviceStatus = (deviceType, callback) => {
17
18
  throw new Error('device width must be a integer');
18
19
  return;
19
20
  }
21
+ useEventListener('orientationchange', () => callback(width), false);
22
+ useEventListener('resize', () => callback(width), false);
20
23
  onMounted(() => {
21
24
  callback(width);
22
- window.addEventListener('resize', () => callback(width), false);
23
- window.addEventListener('orientationchange', () => callback(width), false);
24
25
  });
25
26
  };
@@ -1,5 +1,4 @@
1
1
  @import '_mixins';
2
- @import '_variables';
3
2
 
4
3
  .page {
5
4
  padding-bottom: 2rem;
@@ -10,51 +9,3 @@
10
9
  padding-top: 0;
11
10
  }
12
11
  }
13
-
14
- .page-meta {
15
- @include content_wrapper;
16
- padding-top: 1rem;
17
- padding-bottom: 1rem;
18
- overflow: auto;
19
-
20
- .meta-item {
21
- cursor: default;
22
- margin-top: 0.8rem;
23
-
24
- .meta-item-label {
25
- font-weight: 500;
26
- color: var(--c-text-lighter);
27
- }
28
-
29
- .meta-item-info {
30
- font-weight: 400;
31
- color: var(--c-text-quote);
32
- }
33
- }
34
-
35
- .edit-link {
36
- display: inline-block;
37
- margin-right: 0.25rem;
38
-
39
- @media print {
40
- display: none;
41
- }
42
- }
43
-
44
- .last-updated {
45
- float: right;
46
- }
47
- }
48
-
49
- @media (max-width: $MQMobile) {
50
- .page-meta {
51
- .last-updated {
52
- font-size: 0.8em;
53
- float: none;
54
- }
55
-
56
- .contributors {
57
- font-size: 0.8em;
58
- }
59
- }
60
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.21",
3
+ "version": "2.0.0-rc.23",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -42,20 +42,20 @@
42
42
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
43
43
  },
44
44
  "dependencies": {
45
- "@vuepress/helper": "~2.0.0-rc.21",
45
+ "@vuepress/helper": "~2.0.0-rc.23",
46
46
  "@vuepress/plugin-active-header-links": "~2.0.0-rc.21",
47
- "@vuepress/plugin-back-to-top": "~2.0.0-rc.21",
47
+ "@vuepress/plugin-back-to-top": "~2.0.0-rc.23",
48
48
  "@vuepress/plugin-container": "~2.0.0-rc.21",
49
- "@vuepress/plugin-copy-code": "~2.0.0-rc.21",
49
+ "@vuepress/plugin-copy-code": "~2.0.0-rc.23",
50
50
  "@vuepress/plugin-external-link-icon": "~2.0.0-rc.21",
51
- "@vuepress/plugin-git": "~2.0.0-rc.21",
52
- "@vuepress/plugin-links-check": "~2.0.0-rc.21",
53
- "@vuepress/plugin-medium-zoom": "~2.0.0-rc.21",
51
+ "@vuepress/plugin-git": "~2.0.0-rc.22",
52
+ "@vuepress/plugin-links-check": "~2.0.0-rc.23",
53
+ "@vuepress/plugin-medium-zoom": "~2.0.0-rc.23",
54
54
  "@vuepress/plugin-nprogress": "~2.0.0-rc.21",
55
55
  "@vuepress/plugin-palette": "~2.0.0-rc.21",
56
56
  "@vuepress/plugin-prismjs": "~2.0.0-rc.21",
57
- "@vuepress/plugin-seo": "~2.0.0-rc.21",
58
- "@vuepress/plugin-sitemap": "~2.0.0-rc.21",
57
+ "@vuepress/plugin-seo": "~2.0.0-rc.23",
58
+ "@vuepress/plugin-sitemap": "~2.0.0-rc.23",
59
59
  "@vuepress/plugin-theme-data": "~2.0.0-rc.21",
60
60
  "@vueuse/core": "^10.9.0",
61
61
  "sass": "^1.72.0",
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "014780ab182c15249ac9d27cee31d080f9ac01cd"
76
+ "gitHead": "18ec6690325db7c130659b59a74d4f3ddcffe499"
77
77
  }