@vuepress/theme-default 2.0.0-beta.6 → 2.0.0-beta.61
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/AutoLink.vue +114 -0
- package/lib/client/components/DropdownTransition.vue +21 -0
- package/lib/client/components/Home.vue +15 -0
- package/lib/client/components/HomeContent.vue +5 -0
- package/lib/client/components/HomeFeatures.vue +23 -0
- package/lib/client/components/HomeFooter.vue +17 -0
- package/lib/client/components/HomeHero.vue +98 -0
- package/lib/client/components/Navbar.vue +75 -0
- package/lib/client/components/NavbarBrand.vue +55 -0
- package/lib/client/components/NavbarDropdown.vue +126 -0
- package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +61 -50
- package/lib/{components → client/components}/Page.vue +9 -15
- package/lib/{components → client/components}/PageMeta.vue +51 -66
- package/lib/{components → client/components}/PageNav.vue +44 -57
- package/lib/client/components/Sidebar.vue +13 -0
- package/lib/client/components/SidebarItem.vue +87 -0
- package/lib/client/components/SidebarItems.vue +57 -0
- package/lib/client/components/ToggleColorModeButton.vue +57 -0
- package/lib/client/components/ToggleSidebarButton.vue +24 -0
- package/lib/client/components/global/Badge.vue +31 -0
- package/lib/client/components/global/CodeGroup.d.ts +4 -0
- package/lib/client/components/global/CodeGroup.js +106 -0
- package/lib/client/components/global/CodeGroupItem.vue +31 -0
- package/lib/client/components/global/index.d.ts +4 -0
- package/lib/client/components/global/index.js +4 -0
- package/lib/client/composables/index.d.ts +6 -0
- package/lib/client/composables/index.js +6 -0
- package/lib/client/composables/useDarkMode.d.ts +12 -0
- package/lib/client/composables/useDarkMode.js +57 -0
- package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
- package/lib/{composables → client/composables}/useNavLink.js +5 -2
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
- package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +2 -2
- package/lib/{composables → client/composables}/useScrollPromise.js +1 -1
- package/lib/client/composables/useSidebarItems.d.ts +36 -0
- package/lib/client/composables/useSidebarItems.js +118 -0
- package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
- package/lib/{composables → client/composables}/useThemeData.js +1 -1
- package/lib/client/config.d.ts +3 -0
- package/lib/client/config.js +44 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +3 -0
- package/lib/client/layouts/Layout.vue +134 -0
- package/lib/client/layouts/NotFound.vue +27 -0
- package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
- package/lib/client/styles/_variables.scss +6 -0
- package/lib/{styles → client/styles}/arrow.scss +4 -6
- package/lib/client/styles/badge.scss +34 -0
- package/lib/{styles → client/styles}/code-group.scss +9 -2
- package/lib/{styles → client/styles}/code.scss +35 -49
- package/lib/client/styles/custom-container.scss +140 -0
- package/lib/{styles → client/styles}/home.scss +32 -24
- package/lib/{styles → client/styles}/index.scss +4 -4
- package/lib/client/styles/layout.scss +199 -0
- package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +36 -50
- package/lib/client/styles/navbar.scss +197 -0
- package/lib/client/styles/normalize.scss +200 -0
- package/lib/{styles → client/styles}/page.scss +24 -8
- package/lib/client/styles/sidebar.scss +134 -0
- package/lib/client/styles/transitions.scss +22 -0
- package/lib/client/styles/vars-dark.scss +68 -0
- package/lib/client/styles/vars.scss +149 -0
- package/lib/client/utils/index.d.ts +3 -0
- package/lib/client/utils/index.js +3 -0
- package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
- package/lib/client/utils/isActiveSidebarItem.js +20 -0
- package/lib/{utils → client/utils}/resolveEditLink.d.ts +2 -2
- package/lib/{utils → client/utils}/resolveEditLink.js +15 -9
- package/lib/client/utils/resolveRepoType.d.ts +2 -0
- package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
- package/lib/node/defaultTheme.d.ts +10 -0
- package/lib/node/defaultTheme.js +117 -0
- package/lib/node/index.d.ts +5 -5
- package/lib/node/index.js +5 -17
- package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
- package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +13 -13
- package/lib/node/utils/index.d.ts +2 -0
- package/lib/node/utils/index.js +2 -0
- package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
- package/lib/node/utils/resolveContainerPluginOptions.js +17 -0
- package/lib/shared/index.d.ts +3 -0
- package/lib/shared/index.js +3 -0
- package/lib/shared/nav.d.ts +42 -0
- package/lib/shared/nav.js +1 -0
- package/lib/{types → shared}/options.d.ts +51 -13
- package/lib/shared/options.js +1 -0
- package/lib/{types → shared}/page.d.ts +15 -6
- package/lib/shared/page.js +1 -0
- package/package.json +49 -29
- package/templates/build.html +33 -0
- package/CHANGELOG.md +0 -376
- 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/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/useSidebarItems.d.ts +0 -31
- package/lib/composables/useSidebarItems.js +0 -114
- 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/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/styles/_normalize.scss +0 -148
- package/lib/styles/_variables.scss +0 -34
- package/lib/styles/badge.scss +0 -33
- package/lib/styles/custom-container.scss +0 -78
- package/lib/styles/layout.scss +0 -194
- package/lib/styles/navbar.scss +0 -141
- 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/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.js +0 -2
- 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/resolveRepoType.d.ts +0 -2
- /package/lib/{composables → client/composables}/useScrollPromise.d.ts +0 -0
- /package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
- /package/lib/{styles → client/styles}/toc.scss +0 -0
package/lib/clientAppEnhance.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineClientAppEnhance } from '@vuepress/client';
|
|
2
|
-
import Badge from './components/global/Badge.vue';
|
|
3
|
-
import CodeGroup from './components/global/CodeGroup';
|
|
4
|
-
import CodeGroupItem from './components/global/CodeGroupItem.vue';
|
|
5
|
-
import OutboundLink from './components/global/OutboundLink.vue';
|
|
6
|
-
import { useScrollPromise } from './composables';
|
|
7
|
-
import './styles/index.scss';
|
|
8
|
-
export default defineClientAppEnhance(({ app, router }) => {
|
|
9
|
-
/* eslint-disable vue/match-component-file-name */
|
|
10
|
-
app.component('Badge', Badge);
|
|
11
|
-
app.component('CodeGroup', CodeGroup);
|
|
12
|
-
app.component('CodeGroupItem', CodeGroupItem);
|
|
13
|
-
// unregister the built-in `<OutboundLink>` to avoid warning
|
|
14
|
-
delete app._context.components.OutboundLink;
|
|
15
|
-
// override the built-in `<OutboundLink>`
|
|
16
|
-
app.component('OutboundLink', OutboundLink);
|
|
17
|
-
// docsearch feature might not be commonly used, so we don't put it
|
|
18
|
-
// into dependencies of default theme, but it is supported
|
|
19
|
-
if (typeof DOCSEARCH_PROPS === 'undefined') {
|
|
20
|
-
// register a mock `<Docsearch>` if docsearch plugin is not enabled
|
|
21
|
-
app.component('Docsearch', () => null);
|
|
22
|
-
}
|
|
23
|
-
/* eslint-enable vue/match-component-file-name */
|
|
24
|
-
// handle scrollBehavior with transition
|
|
25
|
-
const scrollBehavior = router.options.scrollBehavior;
|
|
26
|
-
router.options.scrollBehavior = async (...args) => {
|
|
27
|
-
await useScrollPromise().wait();
|
|
28
|
-
return scrollBehavior(...args);
|
|
29
|
-
};
|
|
30
|
-
});
|
package/lib/clientAppSetup.d.ts
DELETED
package/lib/clientAppSetup.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { computed, provide } from 'vue';
|
|
2
|
-
import { defineClientAppSetup, usePageFrontmatter } from '@vuepress/client';
|
|
3
|
-
import { resolveSidebarItems, sidebarItemsSymbol, useThemeLocaleData, } from './composables';
|
|
4
|
-
export default defineClientAppSetup(() => {
|
|
5
|
-
// we need to access sidebar items in multiple components
|
|
6
|
-
// so we make it global computed
|
|
7
|
-
const themeLocale = useThemeLocaleData();
|
|
8
|
-
const frontmatter = usePageFrontmatter();
|
|
9
|
-
const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value));
|
|
10
|
-
provide(sidebarItemsSymbol, sidebarItems);
|
|
11
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="dropdown-wrapper" :class="{ open }">
|
|
3
|
-
<button
|
|
4
|
-
class="dropdown-title"
|
|
5
|
-
type="button"
|
|
6
|
-
:aria-label="dropdownAriaLabel"
|
|
7
|
-
@click="handleDropdown"
|
|
8
|
-
>
|
|
9
|
-
<span class="title">{{ item.text }}</span>
|
|
10
|
-
<span class="arrow down" />
|
|
11
|
-
</button>
|
|
12
|
-
|
|
13
|
-
<button
|
|
14
|
-
class="mobile-dropdown-title"
|
|
15
|
-
type="button"
|
|
16
|
-
:aria-label="dropdownAriaLabel"
|
|
17
|
-
@click="open = !open"
|
|
18
|
-
>
|
|
19
|
-
<span class="title">{{ item.text }}</span>
|
|
20
|
-
<span class="arrow" :class="open ? 'down' : 'right'" />
|
|
21
|
-
</button>
|
|
22
|
-
|
|
23
|
-
<!-- Transition will somehow break the Select Languages dropdown -->
|
|
24
|
-
<!-- So we remove DropdownTransition until we figure out the reason -->
|
|
25
|
-
<ul v-show="open" class="nav-dropdown">
|
|
26
|
-
<li
|
|
27
|
-
v-for="(child, index) in item.children"
|
|
28
|
-
:key="child.link || index"
|
|
29
|
-
class="dropdown-item"
|
|
30
|
-
>
|
|
31
|
-
<template v-if="child.children">
|
|
32
|
-
<h4 class="dropdown-subtitle">
|
|
33
|
-
<NavLink
|
|
34
|
-
v-if="child.link"
|
|
35
|
-
:item="child"
|
|
36
|
-
@focusout="
|
|
37
|
-
isLastItemOfArray(child, item.children) &&
|
|
38
|
-
child.children.length === 0 &&
|
|
39
|
-
(open = false)
|
|
40
|
-
"
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
<span v-else>{{ child.text }}</span>
|
|
44
|
-
</h4>
|
|
45
|
-
|
|
46
|
-
<ul class="dropdown-subitem-wrapper">
|
|
47
|
-
<li
|
|
48
|
-
v-for="grandchild in child.children"
|
|
49
|
-
:key="grandchild.link"
|
|
50
|
-
class="dropdown-subitem"
|
|
51
|
-
>
|
|
52
|
-
<NavLink
|
|
53
|
-
:item="grandchild"
|
|
54
|
-
@focusout="
|
|
55
|
-
isLastItemOfArray(grandchild, child.children) &&
|
|
56
|
-
isLastItemOfArray(child, item.children) &&
|
|
57
|
-
(open = false)
|
|
58
|
-
"
|
|
59
|
-
/>
|
|
60
|
-
</li>
|
|
61
|
-
</ul>
|
|
62
|
-
</template>
|
|
63
|
-
|
|
64
|
-
<template v-else>
|
|
65
|
-
<NavLink
|
|
66
|
-
:item="child"
|
|
67
|
-
@focusout="
|
|
68
|
-
isLastItemOfArray(child, item.children) && (open = false)
|
|
69
|
-
"
|
|
70
|
-
/>
|
|
71
|
-
</template>
|
|
72
|
-
</li>
|
|
73
|
-
</ul>
|
|
74
|
-
</div>
|
|
75
|
-
</template>
|
|
76
|
-
|
|
77
|
-
<script lang="ts">
|
|
78
|
-
import { computed, defineComponent, ref, toRefs, watch } from 'vue'
|
|
79
|
-
import type { PropType } from 'vue'
|
|
80
|
-
import { useRoute } from 'vue-router'
|
|
81
|
-
import type { NavGroup, NavItem } from '../types'
|
|
82
|
-
import NavLink from './NavLink.vue'
|
|
83
|
-
|
|
84
|
-
export default defineComponent({
|
|
85
|
-
name: 'DropdownLink',
|
|
86
|
-
|
|
87
|
-
components: {
|
|
88
|
-
NavLink,
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
props: {
|
|
92
|
-
item: {
|
|
93
|
-
type: Object as PropType<NavGroup<NavItem>>,
|
|
94
|
-
required: true,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
setup(props) {
|
|
99
|
-
const { item } = toRefs(props)
|
|
100
|
-
const dropdownAriaLabel = computed(
|
|
101
|
-
() => item.value.ariaLabel || item.value.text
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
const open = ref(false)
|
|
105
|
-
const route = useRoute()
|
|
106
|
-
watch(
|
|
107
|
-
() => route.path,
|
|
108
|
-
() => {
|
|
109
|
-
open.value = false
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Open the dropdown when user tab and click from keyboard.
|
|
115
|
-
*
|
|
116
|
-
* Use event.detail to detect tab and click from keyboard.
|
|
117
|
-
* The Tab + Click is UIEvent > KeyboardEvent, so the detail is 0.
|
|
118
|
-
*
|
|
119
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
120
|
-
*/
|
|
121
|
-
const handleDropdown = (e): void => {
|
|
122
|
-
const isTriggerByTab = e.detail === 0
|
|
123
|
-
if (isTriggerByTab) {
|
|
124
|
-
open.value = !open.value
|
|
125
|
-
} else {
|
|
126
|
-
open.value = false
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
|
|
131
|
-
arr[arr.length - 1] === item
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
open,
|
|
135
|
-
dropdownAriaLabel,
|
|
136
|
-
handleDropdown,
|
|
137
|
-
isLastItemOfArray,
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
})
|
|
141
|
-
</script>
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Transition
|
|
3
|
-
name="dropdown"
|
|
4
|
-
@enter="setHeight"
|
|
5
|
-
@after-enter="unsetHeight"
|
|
6
|
-
@before-leave="setHeight"
|
|
7
|
-
>
|
|
8
|
-
<slot />
|
|
9
|
-
</Transition>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script lang="ts">
|
|
13
|
-
import { defineComponent } from 'vue'
|
|
14
|
-
|
|
15
|
-
export default defineComponent({
|
|
16
|
-
name: 'DropdownTransition',
|
|
17
|
-
|
|
18
|
-
setup() {
|
|
19
|
-
const setHeight = (items): void => {
|
|
20
|
-
// explicitly set height so that it can be transitioned
|
|
21
|
-
items.style.height = items.scrollHeight + 'px'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const unsetHeight = (items): void => {
|
|
25
|
-
items.style.height = ''
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
setHeight,
|
|
30
|
-
unsetHeight,
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
</script>
|
package/lib/components/Home.vue
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<main class="home" :aria-labelledby="heroText ? 'main-title' : null">
|
|
3
|
-
<header class="hero">
|
|
4
|
-
<img v-if="heroImage" :src="heroImage" :alt="heroAlt" />
|
|
5
|
-
|
|
6
|
-
<h1 v-if="heroText" id="main-title">
|
|
7
|
-
{{ heroText }}
|
|
8
|
-
</h1>
|
|
9
|
-
|
|
10
|
-
<p v-if="tagline" class="description">
|
|
11
|
-
{{ tagline }}
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
<p v-if="actions.length" class="actions">
|
|
15
|
-
<NavLink
|
|
16
|
-
v-for="action in actions"
|
|
17
|
-
:key="action.text"
|
|
18
|
-
class="action-button"
|
|
19
|
-
:class="[action.type]"
|
|
20
|
-
:item="action"
|
|
21
|
-
/>
|
|
22
|
-
</p>
|
|
23
|
-
</header>
|
|
24
|
-
|
|
25
|
-
<div v-if="features.length" class="features">
|
|
26
|
-
<div v-for="feature in features" :key="feature.title" class="feature">
|
|
27
|
-
<h2>{{ feature.title }}</h2>
|
|
28
|
-
<p>{{ feature.details }}</p>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<div class="theme-default-content custom">
|
|
33
|
-
<Content />
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<template v-if="footer">
|
|
37
|
-
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
38
|
-
<div v-if="footerHtml" class="footer" v-html="footer" />
|
|
39
|
-
<div v-else class="footer" v-text="footer" />
|
|
40
|
-
</template>
|
|
41
|
-
</main>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
import { computed, defineComponent } from 'vue'
|
|
46
|
-
import {
|
|
47
|
-
usePageFrontmatter,
|
|
48
|
-
useSiteLocaleData,
|
|
49
|
-
withBase,
|
|
50
|
-
} from '@vuepress/client'
|
|
51
|
-
import { isArray } from '@vuepress/shared'
|
|
52
|
-
import type { DefaultThemeHomePageFrontmatter } from '../types'
|
|
53
|
-
import NavLink from './NavLink.vue'
|
|
54
|
-
|
|
55
|
-
export default defineComponent({
|
|
56
|
-
name: 'Home',
|
|
57
|
-
|
|
58
|
-
components: {
|
|
59
|
-
NavLink,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
setup() {
|
|
63
|
-
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
|
|
64
|
-
const siteLocale = useSiteLocaleData()
|
|
65
|
-
|
|
66
|
-
const heroImage = computed(() => {
|
|
67
|
-
if (!frontmatter.value.heroImage) {
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return withBase(frontmatter.value.heroImage)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
const heroText = computed(() => {
|
|
75
|
-
if (frontmatter.value.heroText === null) {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
return frontmatter.value.heroText || siteLocale.value.title || 'Hello'
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const heroAlt = computed(
|
|
82
|
-
() => frontmatter.value.heroAlt || heroText.value || 'hero'
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const tagline = computed(() => {
|
|
86
|
-
if (frontmatter.value.tagline === null) {
|
|
87
|
-
return null
|
|
88
|
-
}
|
|
89
|
-
return (
|
|
90
|
-
frontmatter.value.tagline ||
|
|
91
|
-
siteLocale.value.description ||
|
|
92
|
-
'Welcome to your VuePress site'
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
const actions = computed(() => {
|
|
97
|
-
if (!isArray(frontmatter.value.actions)) {
|
|
98
|
-
return []
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return frontmatter.value.actions.map(
|
|
102
|
-
({ text, link, type = 'primary' }) => ({
|
|
103
|
-
text,
|
|
104
|
-
link,
|
|
105
|
-
type,
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const features = computed(() => {
|
|
111
|
-
if (isArray(frontmatter.value.features)) {
|
|
112
|
-
return frontmatter.value.features
|
|
113
|
-
}
|
|
114
|
-
return []
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const footer = computed(() => frontmatter.value.footer)
|
|
118
|
-
|
|
119
|
-
const footerHtml = computed(() => frontmatter.value.footerHtml)
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
heroImage,
|
|
123
|
-
heroAlt,
|
|
124
|
-
heroText,
|
|
125
|
-
tagline,
|
|
126
|
-
actions,
|
|
127
|
-
features,
|
|
128
|
-
footer,
|
|
129
|
-
footerHtml,
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
</script>
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<RouterLink
|
|
3
|
-
v-if="isRouterLink"
|
|
4
|
-
class="nav-link"
|
|
5
|
-
:class="{ 'router-link-active': isActiveInSubpath }"
|
|
6
|
-
:to="item.link"
|
|
7
|
-
:aria-label="linkAriaLabel"
|
|
8
|
-
v-bind="$attrs"
|
|
9
|
-
>
|
|
10
|
-
<slot name="before" />
|
|
11
|
-
{{ item.text }}
|
|
12
|
-
<slot name="after" />
|
|
13
|
-
</RouterLink>
|
|
14
|
-
<a
|
|
15
|
-
v-else
|
|
16
|
-
class="nav-link external"
|
|
17
|
-
:href="item.link"
|
|
18
|
-
:rel="linkRel"
|
|
19
|
-
:target="linkTarget"
|
|
20
|
-
:aria-label="linkAriaLabel"
|
|
21
|
-
v-bind="$attrs"
|
|
22
|
-
>
|
|
23
|
-
<slot name="before" />
|
|
24
|
-
{{ item.text }}
|
|
25
|
-
<OutboundLink v-if="isBlankTarget" />
|
|
26
|
-
<slot name="after" />
|
|
27
|
-
</a>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script lang="ts">
|
|
31
|
-
import { computed, defineComponent, toRefs } from 'vue'
|
|
32
|
-
import type { PropType } from 'vue'
|
|
33
|
-
import { useRoute } from 'vue-router'
|
|
34
|
-
import { useSiteData } from '@vuepress/client'
|
|
35
|
-
import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
|
|
36
|
-
import type { NavLink } from '../types'
|
|
37
|
-
|
|
38
|
-
export default defineComponent({
|
|
39
|
-
name: 'NavLink',
|
|
40
|
-
|
|
41
|
-
inheritAttrs: false,
|
|
42
|
-
|
|
43
|
-
props: {
|
|
44
|
-
item: {
|
|
45
|
-
type: Object as PropType<NavLink>,
|
|
46
|
-
required: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
setup(props) {
|
|
51
|
-
const route = useRoute()
|
|
52
|
-
const site = useSiteData()
|
|
53
|
-
const { item } = toRefs(props)
|
|
54
|
-
|
|
55
|
-
// if the link has http protocol
|
|
56
|
-
const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
|
|
57
|
-
// if the link has non-http protocol
|
|
58
|
-
const hasNonHttpProtocal = computed(
|
|
59
|
-
() => isLinkMailto(item.value.link) || isLinkTel(item.value.link)
|
|
60
|
-
)
|
|
61
|
-
// resolve the `target` attr
|
|
62
|
-
const linkTarget = computed(() => {
|
|
63
|
-
if (hasNonHttpProtocal.value) return undefined
|
|
64
|
-
if (item.value.target) return item.value.target
|
|
65
|
-
if (hasHttpProtocol.value) return '_blank'
|
|
66
|
-
return undefined
|
|
67
|
-
})
|
|
68
|
-
// if the `target` attr is '_blank'
|
|
69
|
-
const isBlankTarget = computed(() => linkTarget.value === '_blank')
|
|
70
|
-
// is `<RouterLink>` or not
|
|
71
|
-
const isRouterLink = computed(
|
|
72
|
-
() =>
|
|
73
|
-
!hasHttpProtocol.value &&
|
|
74
|
-
!hasNonHttpProtocal.value &&
|
|
75
|
-
!isBlankTarget.value
|
|
76
|
-
)
|
|
77
|
-
// resolve the `rel` attr
|
|
78
|
-
const linkRel = computed(() => {
|
|
79
|
-
if (hasNonHttpProtocal.value) return undefined
|
|
80
|
-
if (item.value.rel) return item.value.rel
|
|
81
|
-
if (isBlankTarget.value) return 'noopener noreferrer'
|
|
82
|
-
return undefined
|
|
83
|
-
})
|
|
84
|
-
// resolve the `aria-label` attr
|
|
85
|
-
const linkAriaLabel = computed(
|
|
86
|
-
() => item.value.ariaLabel || item.value.text
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
// should be active when current route is a subpath of this link
|
|
90
|
-
const shouldBeActiveInSubpath = computed(() => {
|
|
91
|
-
const localeKeys = Object.keys(site.value.locales)
|
|
92
|
-
if (localeKeys.length) {
|
|
93
|
-
return !localeKeys.some((key) => key === item.value.link)
|
|
94
|
-
}
|
|
95
|
-
return item.value.link !== '/'
|
|
96
|
-
})
|
|
97
|
-
// if this link is active in subpath
|
|
98
|
-
const isActiveInSubpath = computed(() => {
|
|
99
|
-
if (!isRouterLink.value || !shouldBeActiveInSubpath.value) {
|
|
100
|
-
return false
|
|
101
|
-
}
|
|
102
|
-
return route.path.startsWith(item.value.link)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
isActiveInSubpath,
|
|
107
|
-
isBlankTarget,
|
|
108
|
-
isRouterLink,
|
|
109
|
-
linkRel,
|
|
110
|
-
linkTarget,
|
|
111
|
-
linkAriaLabel,
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
})
|
|
115
|
-
</script>
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<header ref="navbar" class="navbar">
|
|
3
|
-
<ToggleSidebarButton @toggle="$emit('toggle-sidebar')" />
|
|
4
|
-
|
|
5
|
-
<span ref="siteBrand">
|
|
6
|
-
<RouterLink :to="siteBrandLink">
|
|
7
|
-
<img
|
|
8
|
-
v-if="siteBrandLogo"
|
|
9
|
-
class="logo"
|
|
10
|
-
:src="withBase(siteBrandLogo)"
|
|
11
|
-
:alt="siteBrandTitle"
|
|
12
|
-
/>
|
|
13
|
-
|
|
14
|
-
<span
|
|
15
|
-
v-if="siteBrandTitle"
|
|
16
|
-
class="site-name"
|
|
17
|
-
:class="{ 'can-hide': siteBrandLogo }"
|
|
18
|
-
>
|
|
19
|
-
{{ siteBrandTitle }}
|
|
20
|
-
</span>
|
|
21
|
-
</RouterLink>
|
|
22
|
-
</span>
|
|
23
|
-
|
|
24
|
-
<div class="navbar-links-wrapper" :style="linksWrapperStyle">
|
|
25
|
-
<slot name="before" />
|
|
26
|
-
<NavbarLinks class="can-hide" />
|
|
27
|
-
<slot name="after" />
|
|
28
|
-
<Docsearch />
|
|
29
|
-
</div>
|
|
30
|
-
</header>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script lang="ts">
|
|
34
|
-
import { computed, defineComponent, onMounted, ref } from 'vue'
|
|
35
|
-
import { useRouteLocale, useSiteLocaleData, withBase } from '@vuepress/client'
|
|
36
|
-
import { useThemeLocaleData } from '../composables'
|
|
37
|
-
import NavbarLinks from './NavbarLinks.vue'
|
|
38
|
-
import ToggleSidebarButton from './ToggleSidebarButton.vue'
|
|
39
|
-
|
|
40
|
-
export default defineComponent({
|
|
41
|
-
name: 'Navbar',
|
|
42
|
-
|
|
43
|
-
components: {
|
|
44
|
-
NavbarLinks,
|
|
45
|
-
ToggleSidebarButton,
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
emits: ['toggle-sidebar'],
|
|
49
|
-
|
|
50
|
-
setup() {
|
|
51
|
-
const routeLocale = useRouteLocale()
|
|
52
|
-
const siteLocale = useSiteLocaleData()
|
|
53
|
-
const themeLocale = useThemeLocaleData()
|
|
54
|
-
|
|
55
|
-
const navbar = ref<HTMLElement | null>(null)
|
|
56
|
-
const siteBrand = ref<HTMLElement | null>(null)
|
|
57
|
-
const siteBrandLink = computed(
|
|
58
|
-
() => themeLocale.value.home || routeLocale.value
|
|
59
|
-
)
|
|
60
|
-
const siteBrandLogo = computed(() => themeLocale.value.logo)
|
|
61
|
-
const siteBrandTitle = computed(() => siteLocale.value.title)
|
|
62
|
-
const linksWrapperMaxWidth = ref(0)
|
|
63
|
-
const linksWrapperStyle = computed(() => {
|
|
64
|
-
if (!linksWrapperMaxWidth.value) {
|
|
65
|
-
return {}
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
maxWidth: linksWrapperMaxWidth.value + 'px',
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
// avoid overlapping of long title and long navbar links
|
|
73
|
-
onMounted(() => {
|
|
74
|
-
// TODO: migrate to css var
|
|
75
|
-
// refer to _variables.scss
|
|
76
|
-
const MOBILE_DESKTOP_BREAKPOINT = 719
|
|
77
|
-
const navbarHorizontalPadding =
|
|
78
|
-
getCssValue(navbar.value, 'paddingLeft') +
|
|
79
|
-
getCssValue(navbar.value, 'paddingRight')
|
|
80
|
-
const handleLinksWrapWidth = (): void => {
|
|
81
|
-
if (window.innerWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
82
|
-
linksWrapperMaxWidth.value = 0
|
|
83
|
-
} else {
|
|
84
|
-
linksWrapperMaxWidth.value =
|
|
85
|
-
navbar.value!.offsetWidth -
|
|
86
|
-
navbarHorizontalPadding -
|
|
87
|
-
(siteBrand.value?.offsetWidth || 0)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
handleLinksWrapWidth()
|
|
91
|
-
window.addEventListener('resize', handleLinksWrapWidth, false)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
navbar,
|
|
96
|
-
siteBrand,
|
|
97
|
-
siteBrandLink,
|
|
98
|
-
siteBrandLogo,
|
|
99
|
-
siteBrandTitle,
|
|
100
|
-
linksWrapperStyle,
|
|
101
|
-
withBase,
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
function getCssValue(el: HTMLElement | null, property: string): number {
|
|
107
|
-
// NOTE: Known bug, will return 'auto' if style value is 'auto'
|
|
108
|
-
const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
|
|
109
|
-
property
|
|
110
|
-
]
|
|
111
|
-
const num = Number.parseInt(val, 10)
|
|
112
|
-
return Number.isNaN(num) ? 0 : num
|
|
113
|
-
}
|
|
114
|
-
</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>
|