@vuepress/theme-default 2.0.0-rc.69 → 2.0.0-rc.70
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/client/components/VPAutoLink.vue +32 -0
- package/lib/client/components/VPHomeHero.vue +4 -5
- package/lib/client/components/VPNavbarDropdown.vue +10 -9
- package/lib/client/components/VPNavbarItems.vue +10 -9
- package/lib/client/components/VPPageMeta.vue +3 -3
- package/lib/client/components/VPPageNav.vue +6 -6
- package/lib/client/components/VPSidebar.vue +2 -2
- package/lib/client/components/VPSidebarItem.vue +15 -9
- package/lib/client/components/VPSidebarItems.vue +1 -5
- package/lib/client/composables/useEditLink.js +1 -1
- package/lib/client/composables/useNavbarConfig.js +6 -4
- package/lib/client/composables/useNavbarRepo.js +1 -1
- package/lib/client/composables/useRelatedLinks.js +3 -3
- package/lib/client/composables/useSidebarItems.js +6 -5
- package/lib/client/utils/index.d.ts +1 -2
- package/lib/client/utils/index.js +1 -2
- package/lib/client/utils/isActiveSidebarItem.d.ts +1 -1
- package/lib/client/utils/isActiveSidebarItem.js +2 -2
- package/lib/client/utils/resolveAutoLink.d.ts +9 -0
- package/lib/client/utils/{getAutoLink.js → resolveAutoLink.js} +1 -1
- package/lib/client/utils/resolveEditLink.d.ts +2 -2
- package/lib/client/utils/resolveEditLink.js +3 -3
- package/lib/node/defaultTheme.js +8 -0
- package/package.json +17 -17
- package/lib/client/utils/getAutoLink.d.ts +0 -9
- package/lib/client/utils/isLinkInternal.d.ts +0 -1
- package/lib/client/utils/isLinkInternal.js +0 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VNode } from 'vue'
|
|
3
|
+
import type { AutoLinkConfig } from 'vuepress/client'
|
|
4
|
+
import { AutoLink } from 'vuepress/client'
|
|
5
|
+
|
|
6
|
+
defineProps<{
|
|
7
|
+
/**
|
|
8
|
+
* The auto link config
|
|
9
|
+
*/
|
|
10
|
+
config: AutoLinkConfig
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
defineSlots<{
|
|
14
|
+
default?: (config: AutoLinkConfig) => VNode | VNode[]
|
|
15
|
+
before?: (config: AutoLinkConfig) => VNode | VNode[] | null
|
|
16
|
+
after?: (config: AutoLinkConfig) => VNode | VNode[] | null
|
|
17
|
+
}>()
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<AutoLink :config="config">
|
|
22
|
+
<template v-if="$slots.default" #default>
|
|
23
|
+
<slot v-bind="config" />
|
|
24
|
+
</template>
|
|
25
|
+
<template #before>
|
|
26
|
+
<slot name="before" v-bind="config" />
|
|
27
|
+
</template>
|
|
28
|
+
<template #after>
|
|
29
|
+
<slot name="after" v-bind="config" />
|
|
30
|
+
</template>
|
|
31
|
+
</AutoLink>
|
|
32
|
+
</template>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import { useDarkMode } from '@theme/useDarkMode'
|
|
3
4
|
import type { FunctionalComponent } from 'vue'
|
|
4
5
|
import { computed, h } from 'vue'
|
|
5
6
|
import {
|
|
6
|
-
AutoLink,
|
|
7
7
|
ClientOnly,
|
|
8
8
|
usePageFrontmatter,
|
|
9
9
|
useSiteLocaleData,
|
|
@@ -48,10 +48,9 @@ const actions = computed(() => {
|
|
|
48
48
|
return []
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
return frontmatter.value.actions.map(({
|
|
52
|
-
text,
|
|
53
|
-
link,
|
|
51
|
+
return frontmatter.value.actions.map(({ type = 'primary', ...rest }) => ({
|
|
54
52
|
type,
|
|
53
|
+
...rest,
|
|
55
54
|
}))
|
|
56
55
|
})
|
|
57
56
|
|
|
@@ -88,7 +87,7 @@ const HomeHeroImage: FunctionalComponent = () => {
|
|
|
88
87
|
</p>
|
|
89
88
|
|
|
90
89
|
<p v-if="actions.length" class="vp-hero-actions">
|
|
91
|
-
<
|
|
90
|
+
<VPAutoLink
|
|
92
91
|
v-for="action in actions"
|
|
93
92
|
:key="action.text"
|
|
94
93
|
class="vp-hero-action-button"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import VPDropdownTransition from '@theme/VPDropdownTransition.vue'
|
|
3
4
|
import { useToggle } from '@vueuse/core'
|
|
4
5
|
import { computed, toRefs, watch } from 'vue'
|
|
5
|
-
import {
|
|
6
|
+
import { useRoute } from 'vuepress/client'
|
|
6
7
|
import type { AutoLinkOptions, NavGroup } from '../../shared/index.js'
|
|
7
8
|
|
|
8
9
|
const props = defineProps<{
|
|
@@ -74,7 +75,7 @@ watch(
|
|
|
74
75
|
>
|
|
75
76
|
<template v-if="'children' in child">
|
|
76
77
|
<h4 class="vp-navbar-dropdown-subtitle">
|
|
77
|
-
<
|
|
78
|
+
<VPAutoLink
|
|
78
79
|
v-if="child.link"
|
|
79
80
|
:config="child"
|
|
80
81
|
@focusout="
|
|
@@ -98,7 +99,7 @@ watch(
|
|
|
98
99
|
:key="grandchild.link"
|
|
99
100
|
class="vp-navbar-dropdown-subitem"
|
|
100
101
|
>
|
|
101
|
-
<
|
|
102
|
+
<VPAutoLink
|
|
102
103
|
:config="grandchild"
|
|
103
104
|
@focusout="
|
|
104
105
|
() => {
|
|
@@ -116,7 +117,7 @@ watch(
|
|
|
116
117
|
</template>
|
|
117
118
|
|
|
118
119
|
<template v-else>
|
|
119
|
-
<
|
|
120
|
+
<VPAutoLink
|
|
120
121
|
:config="child"
|
|
121
122
|
@focusout="
|
|
122
123
|
() => {
|
|
@@ -240,13 +241,13 @@ watch(
|
|
|
240
241
|
color: inherit;
|
|
241
242
|
line-height: 1.7rem;
|
|
242
243
|
|
|
243
|
-
|
|
244
|
+
.auto-link {
|
|
244
245
|
position: relative;
|
|
245
246
|
|
|
246
247
|
display: block;
|
|
247
248
|
|
|
248
249
|
margin-bottom: 0;
|
|
249
|
-
padding: 0 1.
|
|
250
|
+
padding: 0 1.25rem;
|
|
250
251
|
border-bottom: none;
|
|
251
252
|
|
|
252
253
|
font-weight: 400;
|
|
@@ -256,7 +257,7 @@ watch(
|
|
|
256
257
|
color: var(--vp-c-accent);
|
|
257
258
|
}
|
|
258
259
|
|
|
259
|
-
&.
|
|
260
|
+
&.auto-link-active {
|
|
260
261
|
color: var(--vp-c-accent);
|
|
261
262
|
|
|
262
263
|
&::after {
|
|
@@ -307,10 +308,10 @@ watch(
|
|
|
307
308
|
padding: 0 1.5rem 0 1.25rem;
|
|
308
309
|
}
|
|
309
310
|
|
|
310
|
-
>
|
|
311
|
+
> .auto-link {
|
|
311
312
|
font-weight: inherit;
|
|
312
313
|
|
|
313
|
-
&.
|
|
314
|
+
&.auto-link-active {
|
|
314
315
|
&::after {
|
|
315
316
|
display: none;
|
|
316
317
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import VPNavbarDropdown from '@theme/VPNavbarDropdown.vue'
|
|
3
4
|
import { useNavbarConfig } from '@theme/useNavbarConfig'
|
|
4
5
|
import { useNavbarRepo } from '@theme/useNavbarRepo'
|
|
@@ -6,7 +7,6 @@ import { useNavbarSelectLanguage } from '@theme/useNavbarSelectLanguage'
|
|
|
6
7
|
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
7
8
|
import { DeviceType, useUpdateDeviceStatus } from '@theme/useUpdateDeviceStatus'
|
|
8
9
|
import { computed, ref } from 'vue'
|
|
9
|
-
import { AutoLink } from 'vuepress/client'
|
|
10
10
|
|
|
11
11
|
const navbarConfig = useNavbarConfig()
|
|
12
12
|
const navbarSelectLanguage = useNavbarSelectLanguage()
|
|
@@ -47,7 +47,7 @@ useUpdateDeviceStatus(
|
|
|
47
47
|
:class="{ mobile: isMobile }"
|
|
48
48
|
:config="item"
|
|
49
49
|
/>
|
|
50
|
-
<
|
|
50
|
+
<VPAutoLink v-else :config="item" />
|
|
51
51
|
</div>
|
|
52
52
|
</nav>
|
|
53
53
|
</template>
|
|
@@ -62,13 +62,12 @@ useUpdateDeviceStatus(
|
|
|
62
62
|
display: none;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
display: inline-block;
|
|
65
|
+
.auto-link {
|
|
67
66
|
color: inherit;
|
|
68
67
|
line-height: 1.4rem;
|
|
69
68
|
|
|
70
69
|
&:hover,
|
|
71
|
-
&.
|
|
70
|
+
&.auto-link-active {
|
|
72
71
|
color: var(--vp-c-text);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -88,16 +87,18 @@ useUpdateDeviceStatus(
|
|
|
88
87
|
margin-left: 0;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
90
|
+
.auto-link {
|
|
92
91
|
&:hover,
|
|
93
|
-
&.
|
|
92
|
+
&.auto-link-active {
|
|
94
93
|
color: var(--vp-c-accent);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
>
|
|
97
|
+
> .auto-link {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
|
|
99
100
|
&:hover,
|
|
100
|
-
&.
|
|
101
|
+
&.auto-link-active {
|
|
101
102
|
margin-bottom: -2px;
|
|
102
103
|
border-bottom: 2px solid var(--vp-c-accent);
|
|
103
104
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import VPEditIcon from '@theme/VPEditIcon.vue'
|
|
3
4
|
import { useContributors } from '@theme/useContributors'
|
|
4
5
|
import { useEditLink } from '@theme/useEditLink'
|
|
5
6
|
import { useLastUpdated } from '@theme/useLastUpdated'
|
|
6
7
|
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
7
|
-
import { AutoLink } from 'vuepress/client'
|
|
8
8
|
|
|
9
9
|
const themeLocale = useThemeLocaleData()
|
|
10
10
|
const editLink = useEditLink()
|
|
@@ -15,11 +15,11 @@ const contributors = useContributors()
|
|
|
15
15
|
<template>
|
|
16
16
|
<footer class="vp-page-meta">
|
|
17
17
|
<div v-if="editLink" class="vp-meta-item edit-link">
|
|
18
|
-
<
|
|
18
|
+
<VPAutoLink class="label" :config="editLink">
|
|
19
19
|
<template #before>
|
|
20
20
|
<VPEditIcon />
|
|
21
21
|
</template>
|
|
22
|
-
</
|
|
22
|
+
</VPAutoLink>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
<div class="vp-meta-item git-info">
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import { useNavigate } from '@theme/useNavigate'
|
|
3
4
|
import { useRelatedLinks } from '@theme/useRelatedLinks'
|
|
4
5
|
import { useThemeLocaleData } from '@theme/useThemeData'
|
|
5
6
|
import { useEventListener } from '@vueuse/core'
|
|
6
7
|
import { computed } from 'vue'
|
|
7
|
-
import { AutoLink } from 'vuepress/client'
|
|
8
8
|
|
|
9
9
|
const themeLocale = useThemeLocaleData()
|
|
10
10
|
const navigate = useNavigate()
|
|
@@ -39,7 +39,7 @@ useEventListener('keydown', (event): void => {
|
|
|
39
39
|
class="vp-page-nav"
|
|
40
40
|
:aria-label="navbarLabel"
|
|
41
41
|
>
|
|
42
|
-
<
|
|
42
|
+
<VPAutoLink v-if="prevLink" class="prev" :config="prevLink">
|
|
43
43
|
<div class="hint">
|
|
44
44
|
<span class="arrow left" />
|
|
45
45
|
{{ themeLocale.prev ?? 'Prev' }}
|
|
@@ -47,9 +47,9 @@ useEventListener('keydown', (event): void => {
|
|
|
47
47
|
<div class="link">
|
|
48
48
|
<span>{{ prevLink.text }}</span>
|
|
49
49
|
</div>
|
|
50
|
-
</
|
|
50
|
+
</VPAutoLink>
|
|
51
51
|
|
|
52
|
-
<
|
|
52
|
+
<VPAutoLink v-if="nextLink" class="next" :config="nextLink">
|
|
53
53
|
<div class="hint">
|
|
54
54
|
{{ themeLocale.next ?? 'Next' }}
|
|
55
55
|
<span class="arrow right" />
|
|
@@ -57,7 +57,7 @@ useEventListener('keydown', (event): void => {
|
|
|
57
57
|
<div class="link">
|
|
58
58
|
<span>{{ nextLink.text }}</span>
|
|
59
59
|
</div>
|
|
60
|
-
</
|
|
60
|
+
</VPAutoLink>
|
|
61
61
|
</nav>
|
|
62
62
|
</template>
|
|
63
63
|
|
|
@@ -87,7 +87,7 @@ useEventListener('keydown', (event): void => {
|
|
|
87
87
|
display: none;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
.
|
|
90
|
+
.auto-link {
|
|
91
91
|
display: inline-block;
|
|
92
92
|
flex-grow: 1;
|
|
93
93
|
|
|
@@ -86,7 +86,7 @@ defineSlots<{
|
|
|
86
86
|
@media (max-width: $MQMobile) {
|
|
87
87
|
display: block;
|
|
88
88
|
|
|
89
|
-
.vp-navbar-dropdown-item
|
|
89
|
+
.vp-navbar-dropdown-item .route-link-active::after {
|
|
90
90
|
top: calc(1rem - 2px);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -97,7 +97,7 @@ defineSlots<{
|
|
|
97
97
|
list-style-type: none;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
.auto-link {
|
|
101
101
|
font-weight: 600;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import VPAutoLink from '@theme/VPAutoLink.vue'
|
|
2
3
|
import VPDropdownTransition from '@theme/VPDropdownTransition.vue'
|
|
4
|
+
import { isActiveSidebarItem } from '@theme/isActiveSidebarItem'
|
|
3
5
|
import { useToggle } from '@vueuse/core'
|
|
4
6
|
import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
|
|
5
|
-
import {
|
|
7
|
+
import { useRoute, useRouter } from 'vuepress/client'
|
|
6
8
|
import type { SidebarItem } from '../typings.js'
|
|
7
|
-
import { isActiveLinkItem } from '../utils/index.js'
|
|
8
9
|
|
|
9
10
|
const props = withDefaults(
|
|
10
11
|
defineProps<{
|
|
@@ -27,7 +28,7 @@ const router = useRouter()
|
|
|
27
28
|
const collapsible = computed(
|
|
28
29
|
() => 'collapsible' in item.value && item.value.collapsible,
|
|
29
30
|
)
|
|
30
|
-
const isActive = computed(() =>
|
|
31
|
+
const isActive = computed(() => isActiveSidebarItem(item.value, route))
|
|
31
32
|
const itemClass = computed(() => ({
|
|
32
33
|
'vp-sidebar-item': true,
|
|
33
34
|
'vp-sidebar-heading': depth.value === 0,
|
|
@@ -61,7 +62,7 @@ onBeforeUnmount(() => {
|
|
|
61
62
|
|
|
62
63
|
<template>
|
|
63
64
|
<li>
|
|
64
|
-
<
|
|
65
|
+
<VPAutoLink v-if="item.link" :class="itemClass" :config="item" />
|
|
65
66
|
<p
|
|
66
67
|
v-else
|
|
67
68
|
tabindex="0"
|
|
@@ -162,13 +163,18 @@ onBeforeUnmount(() => {
|
|
|
162
163
|
color: var(--vp-c-accent);
|
|
163
164
|
font-weight: 600;
|
|
164
165
|
}
|
|
165
|
-
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
.auto-link {
|
|
168
|
+
display: block;
|
|
169
|
+
}
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
&.auto-link {
|
|
172
|
+
display: block;
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
|
|
175
|
+
&:hover {
|
|
176
|
+
color: var(--vp-c-accent);
|
|
177
|
+
}
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
</style>
|
|
@@ -17,7 +17,7 @@ onMounted(() => {
|
|
|
17
17
|
|
|
18
18
|
// get the active sidebar item DOM, whose href equals to the current route
|
|
19
19
|
const activeSidebarItem = document.querySelector(
|
|
20
|
-
`.vp-sidebar
|
|
20
|
+
`.vp-sidebar .vp-sidebar-item.auto-link[href="${route.path}${hash}"]`,
|
|
21
21
|
)
|
|
22
22
|
if (!activeSidebarItem) return
|
|
23
23
|
|
|
@@ -74,9 +74,5 @@ onMounted(() => {
|
|
|
74
74
|
padding: 0;
|
|
75
75
|
list-style-type: none;
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
a {
|
|
79
|
-
display: inline-block;
|
|
80
|
-
}
|
|
81
77
|
}
|
|
82
78
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { resolveEditLink } from '@theme/resolveEditLink';
|
|
1
2
|
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
2
3
|
import { computed } from 'vue';
|
|
3
4
|
import { usePageData, usePageFrontmatter } from 'vuepress/client';
|
|
4
|
-
import { resolveEditLink } from '../utils/index.js';
|
|
5
5
|
export const useEditLink = () => {
|
|
6
6
|
const themeLocale = useThemeLocaleData();
|
|
7
7
|
const page = usePageData();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
|
+
import { resolvePrefix } from '@theme/resolvePrefix';
|
|
1
3
|
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
4
|
+
import { isLinkRelative } from '@vuepress/helper/client';
|
|
2
5
|
import { computed } from 'vue';
|
|
3
6
|
import { isString } from 'vuepress/shared';
|
|
4
|
-
import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
|
|
5
7
|
const resolveNavbarItem = (item, prefix = '') => {
|
|
6
8
|
if (isString(item)) {
|
|
7
|
-
return
|
|
9
|
+
return resolveAutoLink(resolvePrefix(prefix, item));
|
|
8
10
|
}
|
|
9
11
|
if ('children' in item) {
|
|
10
12
|
return {
|
|
@@ -14,8 +16,8 @@ const resolveNavbarItem = (item, prefix = '') => {
|
|
|
14
16
|
}
|
|
15
17
|
return {
|
|
16
18
|
...item,
|
|
17
|
-
link:
|
|
18
|
-
?
|
|
19
|
+
link: isLinkRelative(item.link)
|
|
20
|
+
? resolveAutoLink(resolvePrefix(prefix, item.link)).link
|
|
19
21
|
: item.link,
|
|
20
22
|
};
|
|
21
23
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { resolveRepoType } from '@theme/resolveRepoType';
|
|
1
2
|
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
2
3
|
import { computed } from 'vue';
|
|
3
4
|
import { isLinkHttp } from 'vuepress/shared';
|
|
4
|
-
import { resolveRepoType } from '../utils/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* Get navbar config of repository link
|
|
7
7
|
*/
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
1
2
|
import { useSidebarItems } from '@theme/useSidebarItems';
|
|
2
3
|
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
3
4
|
import { computed } from 'vue';
|
|
4
5
|
import { resolveRoute, usePageFrontmatter, useRoute } from 'vuepress/client';
|
|
5
6
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
6
|
-
import { getAutoLink } from '../utils/index.js';
|
|
7
7
|
const resolveFromFrontmatterConfig = (config, currentPath) => {
|
|
8
8
|
if (config === false) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
if (isString(config)) {
|
|
12
|
-
return
|
|
12
|
+
return resolveAutoLink(config, currentPath);
|
|
13
13
|
}
|
|
14
14
|
if (isPlainObject(config)) {
|
|
15
15
|
return {
|
|
16
16
|
...config,
|
|
17
|
-
link:
|
|
17
|
+
link: resolveAutoLink(config.link, currentPath).link,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { resolveAutoLink } from '@theme/resolveAutoLink';
|
|
2
|
+
import { resolvePrefix } from '@theme/resolvePrefix';
|
|
1
3
|
import { useThemeLocaleData } from '@theme/useThemeData';
|
|
2
|
-
import { getHeaders, keys, startsWith } from '@vuepress/helper/client';
|
|
4
|
+
import { getHeaders, isLinkRelative, keys, startsWith, } from '@vuepress/helper/client';
|
|
3
5
|
import { computed, inject, onMounted, provide, ref, watch } from 'vue';
|
|
4
6
|
import { usePageData, usePageFrontmatter, useRoute, useRouteLocale, useRouter, } from 'vuepress/client';
|
|
5
7
|
import { isPlainObject, isString } from 'vuepress/shared';
|
|
6
|
-
import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
|
|
7
8
|
export const headersRef = ref([]);
|
|
8
9
|
export const setupHeaders = () => {
|
|
9
10
|
const router = useRouter();
|
|
@@ -54,12 +55,12 @@ export const resolveSidebarHeadingItem = (page, headers) => [
|
|
|
54
55
|
export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
|
|
55
56
|
const handleChildItem = (item, pathPrefix) => {
|
|
56
57
|
const childItem = isString(item)
|
|
57
|
-
?
|
|
58
|
+
? resolveAutoLink(resolvePrefix(pathPrefix, item))
|
|
58
59
|
: isString(item.link)
|
|
59
60
|
? {
|
|
60
61
|
...item,
|
|
61
|
-
link:
|
|
62
|
-
?
|
|
62
|
+
link: isLinkRelative(item.link)
|
|
63
|
+
? resolveAutoLink(resolvePrefix(pathPrefix, item.link)).link
|
|
63
64
|
: item.link,
|
|
64
65
|
}
|
|
65
66
|
: item;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from './getAutoLink.js';
|
|
2
1
|
export * from './isActiveSidebarItem.js';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './resolveAutoLink.js';
|
|
4
3
|
export * from './resolveEditLink.js';
|
|
5
4
|
export * from './resolvePrefix.js';
|
|
6
5
|
export * from './resolveRepoType.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export * from './getAutoLink.js';
|
|
2
1
|
export * from './isActiveSidebarItem.js';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './resolveAutoLink.js';
|
|
4
3
|
export * from './resolveEditLink.js';
|
|
5
4
|
export * from './resolvePrefix.js';
|
|
6
5
|
export * from './resolveRepoType.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RouteLocationNormalizedLoaded } from 'vuepress/client';
|
|
2
2
|
import type { SidebarItem } from '../typings.js';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const isActiveSidebarItem: (item: SidebarItem, route: RouteLocationNormalizedLoaded) => boolean;
|
|
@@ -9,12 +9,12 @@ const isActiveLink = (link, route) => {
|
|
|
9
9
|
const targetPath = normalizePath(link);
|
|
10
10
|
return currentPath === targetPath;
|
|
11
11
|
};
|
|
12
|
-
export const
|
|
12
|
+
export const isActiveSidebarItem = (item, route) => {
|
|
13
13
|
if (item.link && isActiveLink(item.link, route)) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
if ('children' in item) {
|
|
17
|
-
return item.children.some((child) =>
|
|
17
|
+
return item.children.some((child) => isActiveSidebarItem(child, route));
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
20
20
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AutoLinkOptions } from '../../shared/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve AutoLink props from string
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* - Input: '/README.md'
|
|
7
|
+
* - Output: { text: 'Home', link: '/' }
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveAutoLink: (config: string, currentPath?: string) => AutoLinkOptions;
|
|
@@ -6,7 +6,7 @@ import { resolveRoute } from 'vuepress/client';
|
|
|
6
6
|
* - Input: '/README.md'
|
|
7
7
|
* - Output: { text: 'Home', link: '/' }
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const resolveAutoLink = (config, currentPath) => {
|
|
10
10
|
const { notFound, meta, path } = resolveRoute(config, currentPath);
|
|
11
11
|
return notFound
|
|
12
12
|
? { text: path, link: path }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RepoType } from '
|
|
2
|
-
export declare const
|
|
1
|
+
import type { RepoType } from '@theme/resolveRepoType';
|
|
2
|
+
export declare const EDIT_LINK_PATTERNS: Record<Exclude<RepoType, null>, string>;
|
|
3
3
|
export declare const resolveEditLink: ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }: {
|
|
4
4
|
docsRepo: string;
|
|
5
5
|
docsBranch: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { resolveRepoType } from '@theme/resolveRepoType';
|
|
1
2
|
import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from 'vuepress/shared';
|
|
2
|
-
|
|
3
|
-
export const editLinkPatterns = {
|
|
3
|
+
export const EDIT_LINK_PATTERNS = {
|
|
4
4
|
GitHub: ':repo/edit/:branch/:path',
|
|
5
5
|
GitLab: ':repo/-/edit/:branch/:path',
|
|
6
6
|
Gitee: ':repo/edit/:branch/:path',
|
|
@@ -12,7 +12,7 @@ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
|
|
|
12
12
|
}
|
|
13
13
|
const repoType = resolveRepoType(docsRepo);
|
|
14
14
|
if (repoType !== null) {
|
|
15
|
-
return
|
|
15
|
+
return EDIT_LINK_PATTERNS[repoType];
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
};
|
package/lib/node/defaultTheme.js
CHANGED
|
@@ -39,6 +39,14 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
|
|
|
39
39
|
`@theme/${file.substring(0, file.length - 3)}`,
|
|
40
40
|
path.resolve(__dirname, '../client/composables', file),
|
|
41
41
|
])),
|
|
42
|
+
// use alias to make all utils replaceable
|
|
43
|
+
...Object.fromEntries(fs
|
|
44
|
+
.readdirSync(path.resolve(__dirname, '../client/utils'))
|
|
45
|
+
.filter((file) => file.endsWith('.js'))
|
|
46
|
+
.map((file) => [
|
|
47
|
+
`@theme/${file.substring(0, file.length - 3)}`,
|
|
48
|
+
path.resolve(__dirname, '../client/utils', file),
|
|
49
|
+
])),
|
|
42
50
|
},
|
|
43
51
|
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
|
|
44
52
|
extendsBundlerOptions: (bundlerOptions, app) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.70",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
"templates"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
41
|
-
"@vuepress/plugin-active-header-links": "2.0.0-rc.
|
|
42
|
-
"@vuepress/plugin-back-to-top": "2.0.0-rc.
|
|
43
|
-
"@vuepress/plugin-copy-code": "2.0.0-rc.
|
|
40
|
+
"@vuepress/helper": "2.0.0-rc.70",
|
|
41
|
+
"@vuepress/plugin-active-header-links": "2.0.0-rc.70",
|
|
42
|
+
"@vuepress/plugin-back-to-top": "2.0.0-rc.70",
|
|
43
|
+
"@vuepress/plugin-copy-code": "2.0.0-rc.70",
|
|
44
44
|
"@vuepress/plugin-git": "2.0.0-rc.68",
|
|
45
|
-
"@vuepress/plugin-links-check": "2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-markdown-hint": "2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-markdown-tab": "2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-medium-zoom": "2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-nprogress": "2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-palette": "2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-prismjs": "2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-seo": "2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-sitemap": "2.0.0-rc.
|
|
54
|
-
"@vuepress/plugin-theme-data": "2.0.0-rc.
|
|
55
|
-
"@vueuse/core": "^12.
|
|
45
|
+
"@vuepress/plugin-links-check": "2.0.0-rc.70",
|
|
46
|
+
"@vuepress/plugin-markdown-hint": "2.0.0-rc.70",
|
|
47
|
+
"@vuepress/plugin-markdown-tab": "2.0.0-rc.70",
|
|
48
|
+
"@vuepress/plugin-medium-zoom": "2.0.0-rc.70",
|
|
49
|
+
"@vuepress/plugin-nprogress": "2.0.0-rc.70",
|
|
50
|
+
"@vuepress/plugin-palette": "2.0.0-rc.70",
|
|
51
|
+
"@vuepress/plugin-prismjs": "2.0.0-rc.70",
|
|
52
|
+
"@vuepress/plugin-seo": "2.0.0-rc.70",
|
|
53
|
+
"@vuepress/plugin-sitemap": "2.0.0-rc.70",
|
|
54
|
+
"@vuepress/plugin-theme-data": "2.0.0-rc.70",
|
|
55
|
+
"@vueuse/core": "^12.4.0",
|
|
56
56
|
"vue": "^3.5.13"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "b260336f91beb0feb4572f7e9504cf28572409b4"
|
|
79
79
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AutoLinkOptions } from '../../shared';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve AutoLink props from string
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* - Input: '/README.md'
|
|
7
|
-
* - Output: { text: 'Home', link: '/' }
|
|
8
|
-
*/
|
|
9
|
-
export declare const getAutoLink: (config: string, currentPath?: string) => AutoLinkOptions;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isLinkInternal: (link: string) => boolean;
|