@vuepress/theme-default 2.0.0-beta.5 → 2.0.0-beta.50-pre
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/package.json +45 -29
- package/CHANGELOG.md +0 -368
- package/lib/clientAppEnhance.d.ts +0 -3
- package/lib/clientAppEnhance.js +0 -30
- package/lib/clientAppSetup.d.ts +0 -2
- package/lib/clientAppSetup.js +0 -11
- package/lib/components/DropdownLink.vue +0 -141
- package/lib/components/DropdownTransition.vue +0 -34
- package/lib/components/Home.vue +0 -133
- package/lib/components/NavLink.vue +0 -115
- package/lib/components/Navbar.vue +0 -114
- package/lib/components/NavbarLinks.vue +0 -174
- package/lib/components/Page.vue +0 -30
- package/lib/components/PageMeta.vue +0 -139
- package/lib/components/PageNav.vue +0 -116
- package/lib/components/Sidebar.vue +0 -38
- package/lib/components/SidebarChild.d.ts +0 -6
- package/lib/components/SidebarChild.js +0 -91
- package/lib/components/ToggleSidebarButton.vue +0 -27
- package/lib/components/global/Badge.vue +0 -37
- package/lib/components/global/CodeGroup.d.ts +0 -5
- package/lib/components/global/CodeGroup.js +0 -52
- package/lib/components/global/CodeGroupItem.vue +0 -25
- package/lib/components/global/OutboundLink.vue +0 -30
- package/lib/composables/index.d.ts +0 -5
- package/lib/composables/index.js +0 -5
- package/lib/composables/useNavLink.d.ts +0 -9
- package/lib/composables/useNavLink.js +0 -15
- package/lib/composables/useResolveRouteWithRedirect.d.ts +0 -5
- package/lib/composables/useResolveRouteWithRedirect.js +0 -24
- package/lib/composables/useScrollPromise.d.ts +0 -6
- package/lib/composables/useScrollPromise.js +0 -14
- package/lib/composables/useSidebarItems.d.ts +0 -31
- package/lib/composables/useSidebarItems.js +0 -114
- package/lib/composables/useThemeData.d.ts +0 -4
- package/lib/composables/useThemeData.js +0 -3
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -67
- package/lib/layouts/404.vue +0 -38
- package/lib/layouts/Layout.vue +0 -152
- package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
- package/lib/node/assignDefaultLocaleOptions.js +0 -56
- package/lib/node/index.d.ts +0 -5
- package/lib/node/index.js +0 -17
- package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
- package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
- package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
- package/lib/node/resolveContainerPluginOptions.js +0 -79
- package/lib/node/resolveGitPluginOptions.d.ts +0 -6
- package/lib/node/resolveGitPluginOptions.js +0 -22
- package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
- package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
- package/lib/shim.d.ts +0 -5
- package/lib/styles/_normalize.scss +0 -148
- package/lib/styles/_variables.scss +0 -34
- package/lib/styles/_wrapper.scss +0 -15
- package/lib/styles/arrow.scss +0 -39
- package/lib/styles/badge.scss +0 -33
- package/lib/styles/code-group.scss +0 -62
- package/lib/styles/code.scss +0 -277
- package/lib/styles/custom-container.scss +0 -78
- package/lib/styles/dropdown.scss +0 -197
- package/lib/styles/home.scss +0 -160
- package/lib/styles/index.scss +0 -19
- package/lib/styles/layout.scss +0 -194
- package/lib/styles/navbar.scss +0 -141
- package/lib/styles/page.scss +0 -71
- package/lib/styles/plugins.scss +0 -18
- package/lib/styles/sidebar.scss +0 -152
- package/lib/styles/sr-only.scss +0 -12
- package/lib/styles/toc.scss +0 -5
- package/lib/styles/transitions.scss +0 -13
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -15
- package/lib/types/nav.d.ts +0 -44
- package/lib/types/nav.js +0 -2
- package/lib/types/options.d.ts +0 -205
- package/lib/types/options.js +0 -2
- package/lib/types/page.d.ts +0 -32
- package/lib/types/page.js +0 -2
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -2
- package/lib/utils/resolveEditLink.d.ts +0 -9
- package/lib/utils/resolveEditLink.js +0 -23
- package/lib/utils/resolveRepoType.d.ts +0 -2
- package/lib/utils/resolveRepoType.js +0 -10
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<footer class="page-meta">
|
|
3
|
-
<div v-if="editNavLink" class="meta-item edit-link">
|
|
4
|
-
<NavLink class="meta-item-label" :item="editNavLink" />
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
<div v-if="lastUpdated" class="meta-item last-updated">
|
|
8
|
-
<span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
|
|
9
|
-
<span class="meta-item-info">{{ lastUpdated }}</span>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div
|
|
13
|
-
v-if="contributors && contributors.length"
|
|
14
|
-
class="meta-item contributors"
|
|
15
|
-
>
|
|
16
|
-
<span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
|
|
17
|
-
<span class="meta-item-info">
|
|
18
|
-
<template v-for="(contributor, index) in contributors" :key="index">
|
|
19
|
-
<span class="contributor" :title="`email: ${contributor.email}`">
|
|
20
|
-
{{ contributor.name }}
|
|
21
|
-
</span>
|
|
22
|
-
<template v-if="index !== contributors.length - 1">, </template>
|
|
23
|
-
</template>
|
|
24
|
-
</span>
|
|
25
|
-
</div>
|
|
26
|
-
</footer>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
import { computed, defineComponent } from 'vue'
|
|
31
|
-
import type { ComputedRef } from 'vue'
|
|
32
|
-
import {
|
|
33
|
-
usePageData,
|
|
34
|
-
usePageFrontmatter,
|
|
35
|
-
useSiteLocaleData,
|
|
36
|
-
} from '@vuepress/client'
|
|
37
|
-
import { useThemeLocaleData } from '../composables'
|
|
38
|
-
import type { DefaultThemePageData, NavLink as NavLinkType } from '../types'
|
|
39
|
-
import { resolveEditLink } from '../utils'
|
|
40
|
-
import NavLink from './NavLink.vue'
|
|
41
|
-
|
|
42
|
-
const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
|
|
43
|
-
const themeLocale = useThemeLocaleData()
|
|
44
|
-
const page = usePageData<DefaultThemePageData>()
|
|
45
|
-
const frontmatter = usePageFrontmatter()
|
|
46
|
-
|
|
47
|
-
return computed(() => {
|
|
48
|
-
const showEditLink =
|
|
49
|
-
frontmatter.value.editLink ?? themeLocale.value.editLink ?? true
|
|
50
|
-
if (!showEditLink) {
|
|
51
|
-
return null
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const {
|
|
55
|
-
repo,
|
|
56
|
-
docsRepo = repo,
|
|
57
|
-
docsBranch = 'main',
|
|
58
|
-
docsDir = '',
|
|
59
|
-
editLinkText,
|
|
60
|
-
} = themeLocale.value
|
|
61
|
-
|
|
62
|
-
if (!docsRepo) return null
|
|
63
|
-
|
|
64
|
-
const editLink = resolveEditLink({
|
|
65
|
-
docsRepo,
|
|
66
|
-
docsBranch,
|
|
67
|
-
docsDir,
|
|
68
|
-
filePathRelative: page.value.filePathRelative,
|
|
69
|
-
editLinkPattern: themeLocale.value.editLinkPattern,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
if (!editLink) return null
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
text: editLinkText ?? 'Edit this page',
|
|
76
|
-
link: editLink,
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const useLastUpdated = (): ComputedRef<null | string> => {
|
|
82
|
-
const siteLocale = useSiteLocaleData()
|
|
83
|
-
const themeLocale = useThemeLocaleData()
|
|
84
|
-
const page = usePageData<DefaultThemePageData>()
|
|
85
|
-
const frontmatter = usePageFrontmatter()
|
|
86
|
-
|
|
87
|
-
return computed(() => {
|
|
88
|
-
const showLastUpdated =
|
|
89
|
-
frontmatter.value.lastUpdated ?? themeLocale.value.lastUpdated ?? true
|
|
90
|
-
|
|
91
|
-
if (!showLastUpdated) return null
|
|
92
|
-
|
|
93
|
-
if (!page.value.git?.updatedTime) return null
|
|
94
|
-
|
|
95
|
-
const updatedDate = new Date(page.value.git?.updatedTime)
|
|
96
|
-
|
|
97
|
-
return updatedDate.toLocaleString(siteLocale.value.lang)
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const useContributors = (): ComputedRef<
|
|
102
|
-
null | Required<DefaultThemePageData['git']>['contributors']
|
|
103
|
-
> => {
|
|
104
|
-
const themeLocale = useThemeLocaleData()
|
|
105
|
-
const page = usePageData<DefaultThemePageData>()
|
|
106
|
-
const frontmatter = usePageFrontmatter()
|
|
107
|
-
|
|
108
|
-
return computed(() => {
|
|
109
|
-
const showContributors =
|
|
110
|
-
frontmatter.value.contributors ?? themeLocale.value.contributors ?? true
|
|
111
|
-
|
|
112
|
-
if (!showContributors) return null
|
|
113
|
-
|
|
114
|
-
return page.value.git?.contributors ?? null
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export default defineComponent({
|
|
119
|
-
name: 'PageMeta',
|
|
120
|
-
|
|
121
|
-
components: {
|
|
122
|
-
NavLink,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
setup() {
|
|
126
|
-
const themeLocale = useThemeLocaleData()
|
|
127
|
-
const editNavLink = useEditNavLink()
|
|
128
|
-
const lastUpdated = useLastUpdated()
|
|
129
|
-
const contributors = useContributors()
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
themeLocale,
|
|
133
|
-
editNavLink,
|
|
134
|
-
lastUpdated,
|
|
135
|
-
contributors,
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
})
|
|
139
|
-
</script>
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<nav v-if="prevNavLink || nextNavLink" class="page-nav">
|
|
3
|
-
<p class="inner">
|
|
4
|
-
<span v-if="prevNavLink" class="prev">
|
|
5
|
-
←
|
|
6
|
-
<NavLink :item="prevNavLink" />
|
|
7
|
-
</span>
|
|
8
|
-
|
|
9
|
-
<span v-if="nextNavLink" class="next">
|
|
10
|
-
<NavLink :item="nextNavLink" />
|
|
11
|
-
→
|
|
12
|
-
</span>
|
|
13
|
-
</p>
|
|
14
|
-
</nav>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script lang="ts">
|
|
18
|
-
import { computed, defineComponent } from 'vue'
|
|
19
|
-
import { useRoute } from 'vue-router'
|
|
20
|
-
import { usePageFrontmatter } from '@vuepress/client'
|
|
21
|
-
import { isPlainObject, isString } from '@vuepress/shared'
|
|
22
|
-
import { useNavLink, useSidebarItems } from '../composables'
|
|
23
|
-
import type { NavLink as NavLinkType, ResolvedSidebarItem } from '../types'
|
|
24
|
-
import NavLink from './NavLink.vue'
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Resolve `prev` or `next` config from frontmatter
|
|
28
|
-
*/
|
|
29
|
-
const resolveFromFrontmatterConfig = (
|
|
30
|
-
conf: unknown
|
|
31
|
-
): null | false | NavLinkType => {
|
|
32
|
-
if (conf === false) {
|
|
33
|
-
return null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isString(conf)) {
|
|
37
|
-
return useNavLink(conf)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (isPlainObject<NavLinkType>(conf)) {
|
|
41
|
-
return conf
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Resolve `prev` or `next` config from sidebar items
|
|
49
|
-
*/
|
|
50
|
-
const resolveFromSidebarItems = (
|
|
51
|
-
sidebarItems: ResolvedSidebarItem[],
|
|
52
|
-
currentPath: string,
|
|
53
|
-
offset: number
|
|
54
|
-
): null | NavLinkType => {
|
|
55
|
-
const index = sidebarItems.findIndex((item) => item.link === currentPath)
|
|
56
|
-
if (index !== -1) {
|
|
57
|
-
const targetItem = sidebarItems[index + offset]
|
|
58
|
-
if (!targetItem?.link) {
|
|
59
|
-
return null
|
|
60
|
-
}
|
|
61
|
-
return targetItem as NavLinkType
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const item of sidebarItems) {
|
|
65
|
-
if (item.children) {
|
|
66
|
-
const childResult = resolveFromSidebarItems(
|
|
67
|
-
item.children,
|
|
68
|
-
currentPath,
|
|
69
|
-
offset
|
|
70
|
-
)
|
|
71
|
-
if (childResult) {
|
|
72
|
-
return childResult
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return null
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default defineComponent({
|
|
81
|
-
name: 'PageNav',
|
|
82
|
-
|
|
83
|
-
components: {
|
|
84
|
-
NavLink,
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
setup() {
|
|
88
|
-
const frontmatter = usePageFrontmatter()
|
|
89
|
-
const sidebarItems = useSidebarItems()
|
|
90
|
-
const route = useRoute()
|
|
91
|
-
|
|
92
|
-
const prevNavLink = computed(() => {
|
|
93
|
-
const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
|
|
94
|
-
if (prevConfig !== false) {
|
|
95
|
-
return prevConfig
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const nextNavLink = computed(() => {
|
|
102
|
-
const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
|
|
103
|
-
if (nextConfig !== false) {
|
|
104
|
-
return nextConfig
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
prevNavLink,
|
|
112
|
-
nextNavLink,
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
</script>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<aside class="sidebar">
|
|
3
|
-
<NavbarLinks />
|
|
4
|
-
|
|
5
|
-
<slot name="top" />
|
|
6
|
-
|
|
7
|
-
<ul class="sidebar-links">
|
|
8
|
-
<template v-for="item in sidebarItems" :key="item.link || item.text">
|
|
9
|
-
<SidebarChild :item="item" />
|
|
10
|
-
</template>
|
|
11
|
-
</ul>
|
|
12
|
-
|
|
13
|
-
<slot name="bottom" />
|
|
14
|
-
</aside>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script lang="ts">
|
|
18
|
-
import { defineComponent } from 'vue'
|
|
19
|
-
import { useSidebarItems } from '../composables'
|
|
20
|
-
import NavbarLinks from './NavbarLinks.vue'
|
|
21
|
-
import { SidebarChild } from './SidebarChild'
|
|
22
|
-
|
|
23
|
-
export default defineComponent({
|
|
24
|
-
name: 'Sidebar',
|
|
25
|
-
|
|
26
|
-
components: {
|
|
27
|
-
NavbarLinks,
|
|
28
|
-
SidebarChild,
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
setup() {
|
|
32
|
-
const sidebarItems = useSidebarItems()
|
|
33
|
-
return {
|
|
34
|
-
sidebarItems,
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
</script>
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
import NavLink from './NavLink.vue';
|
|
4
|
-
const normalizePath = (path) => decodeURI(path)
|
|
5
|
-
.replace(/#.*$/, '')
|
|
6
|
-
.replace(/(index)?\.(md|html)$/, '');
|
|
7
|
-
const isActiveLink = (route, link) => {
|
|
8
|
-
if (link === undefined) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (route.hash === link) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
const currentPath = normalizePath(route.path);
|
|
15
|
-
const targetPath = normalizePath(link);
|
|
16
|
-
return currentPath === targetPath;
|
|
17
|
-
};
|
|
18
|
-
const isActiveItem = (route, item) => {
|
|
19
|
-
if (isActiveLink(route, item.link)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (item.children) {
|
|
23
|
-
return item.children.some((child) => isActiveItem(route, child));
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
};
|
|
27
|
-
const renderItem = (item, props) => {
|
|
28
|
-
// if the item has link, render it as `<NavLink>`
|
|
29
|
-
if (item.link) {
|
|
30
|
-
return h(NavLink, {
|
|
31
|
-
...props,
|
|
32
|
-
item,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// if the item only has text, render it as `<p>`
|
|
36
|
-
return h('p', props, item.text);
|
|
37
|
-
};
|
|
38
|
-
const renderChildren = (item, depth) => {
|
|
39
|
-
var _a;
|
|
40
|
-
if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return h('ul', {
|
|
44
|
-
class: {
|
|
45
|
-
'sidebar-sub-headers': depth > 0,
|
|
46
|
-
},
|
|
47
|
-
}, item.children.map((child) => h('li', h(SidebarChild, {
|
|
48
|
-
item: child,
|
|
49
|
-
depth: depth + 1,
|
|
50
|
-
}))));
|
|
51
|
-
};
|
|
52
|
-
export const SidebarChild = ({ item, depth = 0 }) => {
|
|
53
|
-
const route = useRoute();
|
|
54
|
-
const active = isActiveItem(route, item);
|
|
55
|
-
if (item.isGroup) {
|
|
56
|
-
return [
|
|
57
|
-
h('section', {
|
|
58
|
-
class: 'sidebar-group',
|
|
59
|
-
}, [
|
|
60
|
-
renderItem(item, {
|
|
61
|
-
class: {
|
|
62
|
-
'sidebar-heading': true,
|
|
63
|
-
active,
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
renderChildren(item, depth),
|
|
67
|
-
]),
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
return [
|
|
71
|
-
renderItem(item, {
|
|
72
|
-
class: {
|
|
73
|
-
'sidebar-link': true,
|
|
74
|
-
active,
|
|
75
|
-
},
|
|
76
|
-
}),
|
|
77
|
-
renderChildren(item, depth),
|
|
78
|
-
];
|
|
79
|
-
};
|
|
80
|
-
SidebarChild.displayName = 'SidebarChild';
|
|
81
|
-
SidebarChild.props = {
|
|
82
|
-
item: {
|
|
83
|
-
type: Object,
|
|
84
|
-
required: true,
|
|
85
|
-
},
|
|
86
|
-
depth: {
|
|
87
|
-
type: Number,
|
|
88
|
-
required: false,
|
|
89
|
-
default: 0,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="toggle-sidebar-button" @click="$emit('toggle')">
|
|
3
|
-
<svg
|
|
4
|
-
class="icon"
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
aria-hidden="true"
|
|
7
|
-
role="img"
|
|
8
|
-
viewBox="0 0 448 512"
|
|
9
|
-
>
|
|
10
|
-
<path
|
|
11
|
-
fill="currentColor"
|
|
12
|
-
d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
|
|
13
|
-
class=""
|
|
14
|
-
/>
|
|
15
|
-
</svg>
|
|
16
|
-
</div>
|
|
17
|
-
</template>
|
|
18
|
-
|
|
19
|
-
<script lang="ts">
|
|
20
|
-
import { defineComponent } from 'vue'
|
|
21
|
-
|
|
22
|
-
export default defineComponent({
|
|
23
|
-
name: 'ToggleSidebarButton',
|
|
24
|
-
|
|
25
|
-
emits: ['toggle'],
|
|
26
|
-
})
|
|
27
|
-
</script>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span
|
|
3
|
-
class="badge"
|
|
4
|
-
:class="type"
|
|
5
|
-
:style="{
|
|
6
|
-
verticalAlign: vertical,
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
9
|
-
<slot>{{ text }}</slot>
|
|
10
|
-
</span>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script>
|
|
14
|
-
import { defineComponent } from 'vue'
|
|
15
|
-
|
|
16
|
-
export default defineComponent({
|
|
17
|
-
name: 'Badge',
|
|
18
|
-
|
|
19
|
-
props: {
|
|
20
|
-
type: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: false,
|
|
23
|
-
default: 'tip',
|
|
24
|
-
},
|
|
25
|
-
text: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: false,
|
|
28
|
-
default: '',
|
|
29
|
-
},
|
|
30
|
-
vertical: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false,
|
|
33
|
-
default: undefined,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
</script>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
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<{} & {}>, {}>;
|
|
5
|
-
export default _default;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { defineComponent, h, ref } from 'vue';
|
|
2
|
-
export default defineComponent({
|
|
3
|
-
name: 'CodeGroup',
|
|
4
|
-
setup(_, { slots }) {
|
|
5
|
-
// index of current active item
|
|
6
|
-
const activeIndex = ref(-1);
|
|
7
|
-
return () => {
|
|
8
|
-
// NOTICE: here we put the `slots.default()` inside the render function to make
|
|
9
|
-
// the slots reactive, otherwise the slot content won't be changed once the
|
|
10
|
-
// `setup()` function of current component is called
|
|
11
|
-
var _a;
|
|
12
|
-
// get children code-group-item
|
|
13
|
-
const items = (((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || [])
|
|
14
|
-
.filter((vnode) => vnode.type.name === 'CodeGroupItem')
|
|
15
|
-
.map((vnode) => {
|
|
16
|
-
if (vnode.props === null) {
|
|
17
|
-
vnode.props = {};
|
|
18
|
-
}
|
|
19
|
-
return vnode;
|
|
20
|
-
});
|
|
21
|
-
// do not render anything if there is no code-group-item
|
|
22
|
-
if (items.length === 0) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
if (activeIndex.value === -1) {
|
|
26
|
-
// initial state
|
|
27
|
-
// find the index of the code-group-item with `active` props
|
|
28
|
-
activeIndex.value = items.findIndex((vnode) => vnode.props.active === '' || vnode.props.active === true);
|
|
29
|
-
// if there is no `active` props on code-group-item, set the first item active
|
|
30
|
-
if (activeIndex.value === -1) {
|
|
31
|
-
activeIndex.value = 0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
// re-render triggered by modifying `activeIndex` ref
|
|
36
|
-
// set the active item
|
|
37
|
-
items.forEach((vnode, i) => {
|
|
38
|
-
vnode.props.active = i === activeIndex.value;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return h('div', { class: 'code-group' }, [
|
|
42
|
-
h('div', { class: 'code-group__nav' }, h('ul', { class: 'code-group__ul' }, items.map((vnode, i) => h('li', { class: 'code-group__li' }, h('button', {
|
|
43
|
-
class: `code-group__nav-tab${i === activeIndex.value
|
|
44
|
-
? ' code-group__nav-tab-active'
|
|
45
|
-
: ''}`,
|
|
46
|
-
onClick: () => (activeIndex.value = i),
|
|
47
|
-
}, vnode.props.title))))),
|
|
48
|
-
items,
|
|
49
|
-
]);
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="code-group-item" :class="{ 'code-group-item__active': active }">
|
|
3
|
-
<slot />
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import { defineComponent } from 'vue'
|
|
9
|
-
|
|
10
|
-
export default defineComponent({
|
|
11
|
-
name: 'CodeGroupItem',
|
|
12
|
-
|
|
13
|
-
props: {
|
|
14
|
-
title: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
active: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
required: false,
|
|
21
|
-
default: false,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
</script>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<RawOutboundLink>
|
|
3
|
-
<span class="sr-only">{{ themeLocale.openInNewWindow }}</span>
|
|
4
|
-
</RawOutboundLink>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import { defineComponent } from 'vue'
|
|
9
|
-
import { OutboundLink } from '@vuepress/client'
|
|
10
|
-
import { useThemeLocaleData } from '../../composables'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Override the built-in `<OutboundLink>` for a11y
|
|
14
|
-
*/
|
|
15
|
-
export default defineComponent({
|
|
16
|
-
name: 'OutboundLink',
|
|
17
|
-
|
|
18
|
-
components: {
|
|
19
|
-
RawOutboundLink: OutboundLink,
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
setup() {
|
|
23
|
-
const themeLocale = useThemeLocaleData()
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
themeLocale,
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
</script>
|
package/lib/composables/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve NavLink props from string
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* - Input: '/README.md'
|
|
7
|
-
* - Output: { text: 'Home', link: '/' }
|
|
8
|
-
*/
|
|
9
|
-
export const useNavLink = (item) => {
|
|
10
|
-
const resolved = useResolveRouteWithRedirect(item);
|
|
11
|
-
return {
|
|
12
|
-
text: resolved.meta.title || item,
|
|
13
|
-
link: resolved.name === '404' ? item : resolved.fullPath,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useRouter } from 'vue-router';
|
|
2
|
-
import { isFunction, isString } from '@vuepress/shared';
|
|
3
|
-
/**
|
|
4
|
-
* Resolve a route with redirection
|
|
5
|
-
*/
|
|
6
|
-
export const useResolveRouteWithRedirect = (...args) => {
|
|
7
|
-
const router = useRouter();
|
|
8
|
-
const route = router.resolve(...args);
|
|
9
|
-
const lastMatched = route.matched[route.matched.length - 1];
|
|
10
|
-
if (!(lastMatched === null || lastMatched === void 0 ? void 0 : lastMatched.redirect)) {
|
|
11
|
-
return route;
|
|
12
|
-
}
|
|
13
|
-
const { redirect } = lastMatched;
|
|
14
|
-
const resolvedRedirect = isFunction(redirect) ? redirect(route) : redirect;
|
|
15
|
-
const resolvedRedirectObj = isString(resolvedRedirect)
|
|
16
|
-
? { path: resolvedRedirect }
|
|
17
|
-
: resolvedRedirect;
|
|
18
|
-
return useResolveRouteWithRedirect({
|
|
19
|
-
hash: route.hash,
|
|
20
|
-
query: route.query,
|
|
21
|
-
params: route.params,
|
|
22
|
-
...resolvedRedirectObj,
|
|
23
|
-
});
|
|
24
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
let promise = null;
|
|
2
|
-
let promiseResolve = null;
|
|
3
|
-
const scrollPromise = {
|
|
4
|
-
wait: () => promise,
|
|
5
|
-
pending: () => {
|
|
6
|
-
promise = new Promise((resolve) => (promiseResolve = resolve));
|
|
7
|
-
},
|
|
8
|
-
resolve: () => {
|
|
9
|
-
promiseResolve === null || promiseResolve === void 0 ? void 0 : promiseResolve();
|
|
10
|
-
promise = null;
|
|
11
|
-
promiseResolve = null;
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export const useScrollPromise = () => scrollPromise;
|