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

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.
Files changed (142) hide show
  1. package/lib/client/components/AutoLink.vue +114 -0
  2. package/lib/client/components/DropdownTransition.vue +21 -0
  3. package/lib/client/components/Home.vue +15 -0
  4. package/lib/client/components/HomeContent.vue +5 -0
  5. package/lib/client/components/HomeFeatures.vue +23 -0
  6. package/lib/client/components/HomeFooter.vue +17 -0
  7. package/lib/client/components/HomeHero.vue +97 -0
  8. package/lib/client/components/Navbar.vue +75 -0
  9. package/lib/client/components/NavbarBrand.vue +55 -0
  10. package/lib/client/components/NavbarDropdown.vue +126 -0
  11. package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +41 -52
  12. package/lib/{components → client/components}/Page.vue +9 -15
  13. package/lib/{components → client/components}/PageMeta.vue +51 -66
  14. package/lib/{components → client/components}/PageNav.vue +44 -57
  15. package/lib/client/components/Sidebar.vue +13 -0
  16. package/lib/client/components/SidebarItem.vue +87 -0
  17. package/lib/client/components/SidebarItems.vue +57 -0
  18. package/lib/client/components/ToggleColorModeButton.vue +57 -0
  19. package/lib/client/components/ToggleSidebarButton.vue +24 -0
  20. package/lib/client/components/global/Badge.vue +31 -0
  21. package/lib/{components → client/components}/global/CodeGroup.d.ts +2 -3
  22. package/lib/client/components/global/CodeGroup.js +106 -0
  23. package/lib/client/components/global/CodeGroupItem.vue +31 -0
  24. package/lib/client/components/global/index.d.ts +4 -0
  25. package/lib/client/components/global/index.js +4 -0
  26. package/lib/client/composables/index.d.ts +6 -0
  27. package/lib/client/composables/index.js +6 -0
  28. package/lib/client/composables/useDarkMode.d.ts +12 -0
  29. package/lib/client/composables/useDarkMode.js +57 -0
  30. package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
  31. package/lib/{composables → client/composables}/useNavLink.js +5 -2
  32. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
  33. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +2 -2
  34. package/lib/{composables → client/composables}/useScrollPromise.d.ts +0 -0
  35. package/lib/{composables → client/composables}/useScrollPromise.js +1 -1
  36. package/lib/{composables → client/composables}/useSidebarItems.d.ts +12 -7
  37. package/lib/client/composables/useSidebarItems.js +118 -0
  38. package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
  39. package/lib/{composables → client/composables}/useThemeData.js +1 -1
  40. package/lib/client/config.d.ts +3 -0
  41. package/lib/client/config.js +38 -0
  42. package/lib/client/index.d.ts +3 -0
  43. package/lib/client/index.js +3 -0
  44. package/lib/client/layouts/404.vue +27 -0
  45. package/lib/client/layouts/Layout.vue +134 -0
  46. package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
  47. package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
  48. package/lib/client/styles/_variables.scss +11 -0
  49. package/lib/{styles → client/styles}/arrow.scss +4 -6
  50. package/lib/{styles → client/styles}/badge.scss +9 -11
  51. package/lib/{styles → client/styles}/code-group.scss +9 -2
  52. package/lib/{styles → client/styles}/code.scss +26 -37
  53. package/lib/client/styles/custom-container.scss +88 -0
  54. package/lib/{styles → client/styles}/home.scss +32 -24
  55. package/lib/{styles → client/styles}/index.scss +4 -4
  56. package/lib/{styles → client/styles}/layout.scss +70 -66
  57. package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +37 -47
  58. package/lib/{styles → client/styles}/navbar.scss +70 -34
  59. package/lib/client/styles/normalize.scss +177 -0
  60. package/lib/{styles → client/styles}/page.scss +20 -8
  61. package/lib/client/styles/sidebar.scss +134 -0
  62. package/lib/{styles → client/styles}/toc.scss +0 -0
  63. package/lib/client/styles/transitions.scss +22 -0
  64. package/lib/client/styles/vars-dark.scss +46 -0
  65. package/lib/client/styles/vars.scss +133 -0
  66. package/lib/client/utils/index.d.ts +3 -0
  67. package/lib/client/utils/index.js +3 -0
  68. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  69. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  70. package/lib/{utils → client/utils}/resolveEditLink.d.ts +2 -2
  71. package/lib/{utils → client/utils}/resolveEditLink.js +15 -9
  72. package/lib/client/utils/resolveRepoType.d.ts +2 -0
  73. package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
  74. package/lib/node/defaultTheme.d.ts +10 -0
  75. package/lib/node/defaultTheme.js +120 -0
  76. package/lib/node/index.d.ts +5 -5
  77. package/lib/node/index.js +5 -17
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
  79. package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +13 -13
  80. package/lib/node/utils/index.d.ts +2 -0
  81. package/lib/node/utils/index.js +2 -0
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
  83. package/lib/node/utils/resolveContainerPluginOptions.js +17 -0
  84. package/lib/shared/index.d.ts +3 -0
  85. package/lib/shared/index.js +3 -0
  86. package/lib/{types → shared}/nav.d.ts +11 -12
  87. package/lib/shared/nav.js +1 -0
  88. package/lib/{types → shared}/options.d.ts +49 -11
  89. package/lib/shared/options.js +1 -0
  90. package/lib/{types → shared}/page.d.ts +14 -6
  91. package/lib/shared/page.js +1 -0
  92. package/package.json +47 -29
  93. package/templates/build.html +33 -0
  94. package/CHANGELOG.md +0 -368
  95. package/lib/clientAppEnhance.d.ts +0 -3
  96. package/lib/clientAppEnhance.js +0 -30
  97. package/lib/clientAppSetup.d.ts +0 -2
  98. package/lib/clientAppSetup.js +0 -11
  99. package/lib/components/DropdownLink.vue +0 -141
  100. package/lib/components/DropdownTransition.vue +0 -34
  101. package/lib/components/Home.vue +0 -133
  102. package/lib/components/NavLink.vue +0 -115
  103. package/lib/components/Navbar.vue +0 -114
  104. package/lib/components/Sidebar.vue +0 -38
  105. package/lib/components/SidebarChild.d.ts +0 -6
  106. package/lib/components/SidebarChild.js +0 -91
  107. package/lib/components/ToggleSidebarButton.vue +0 -27
  108. package/lib/components/global/Badge.vue +0 -37
  109. package/lib/components/global/CodeGroup.js +0 -52
  110. package/lib/components/global/CodeGroupItem.vue +0 -25
  111. package/lib/components/global/OutboundLink.vue +0 -30
  112. package/lib/composables/index.d.ts +0 -5
  113. package/lib/composables/index.js +0 -5
  114. package/lib/composables/useSidebarItems.js +0 -114
  115. package/lib/index.d.ts +0 -6
  116. package/lib/index.js +0 -67
  117. package/lib/layouts/404.vue +0 -38
  118. package/lib/layouts/Layout.vue +0 -152
  119. package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
  120. package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  121. package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
  122. package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
  123. package/lib/node/resolveContainerPluginOptions.js +0 -79
  124. package/lib/node/resolveGitPluginOptions.d.ts +0 -6
  125. package/lib/node/resolveGitPluginOptions.js +0 -22
  126. package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
  127. package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
  128. package/lib/styles/_normalize.scss +0 -148
  129. package/lib/styles/_variables.scss +0 -34
  130. package/lib/styles/custom-container.scss +0 -78
  131. package/lib/styles/plugins.scss +0 -18
  132. package/lib/styles/sidebar.scss +0 -152
  133. package/lib/styles/sr-only.scss +0 -12
  134. package/lib/styles/transitions.scss +0 -13
  135. package/lib/types/index.d.ts +0 -3
  136. package/lib/types/index.js +0 -15
  137. package/lib/types/nav.js +0 -2
  138. package/lib/types/options.js +0 -2
  139. package/lib/types/page.js +0 -2
  140. package/lib/utils/index.d.ts +0 -2
  141. package/lib/utils/index.js +0 -2
  142. package/lib/utils/resolveRepoType.d.ts +0 -2
@@ -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>
@@ -1,6 +0,0 @@
1
- import type { FunctionalComponent } from 'vue';
2
- import type { ResolvedSidebarItem } from '../types';
3
- export declare const SidebarChild: FunctionalComponent<{
4
- item: ResolvedSidebarItem;
5
- depth?: number;
6
- }>;
@@ -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,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>
@@ -1,5 +0,0 @@
1
- export * from './useNavLink';
2
- export * from './useResolveRouteWithRedirect';
3
- export * from './useScrollPromise';
4
- export * from './useSidebarItems';
5
- export * from './useThemeData';
@@ -1,5 +0,0 @@
1
- export * from './useNavLink';
2
- export * from './useResolveRouteWithRedirect';
3
- export * from './useScrollPromise';
4
- export * from './useSidebarItems';
5
- export * from './useThemeData';