@vuepress/theme-default 2.0.0-beta.4 → 2.0.0-beta.40

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 (132) hide show
  1. package/lib/{clientAppEnhance.d.ts → client/clientAppEnhance.d.ts} +0 -0
  2. package/lib/client/clientAppEnhance.js +34 -0
  3. package/lib/{clientAppSetup.d.ts → client/clientAppSetup.d.ts} +0 -0
  4. package/lib/client/clientAppSetup.js +6 -0
  5. package/lib/client/components/AutoLink.vue +113 -0
  6. package/lib/client/components/DropdownTransition.vue +21 -0
  7. package/lib/client/components/Home.vue +15 -0
  8. package/lib/client/components/HomeContent.vue +5 -0
  9. package/lib/client/components/HomeFeatures.vue +23 -0
  10. package/lib/client/components/HomeFooter.vue +17 -0
  11. package/lib/client/components/HomeHero.vue +97 -0
  12. package/lib/client/components/Navbar.vue +76 -0
  13. package/lib/client/components/NavbarBrand.vue +55 -0
  14. package/lib/client/components/NavbarDropdown.vue +126 -0
  15. package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +27 -47
  16. package/lib/{components → client/components}/Page.vue +5 -15
  17. package/lib/{components → client/components}/PageMeta.vue +48 -59
  18. package/lib/{components → client/components}/PageNav.vue +43 -56
  19. package/lib/client/components/Sidebar.vue +13 -0
  20. package/lib/client/components/SidebarItem.vue +80 -0
  21. package/lib/client/components/SidebarItems.vue +54 -0
  22. package/lib/client/components/ToggleDarkModeButton.vue +57 -0
  23. package/lib/client/components/ToggleSidebarButton.vue +24 -0
  24. package/lib/client/components/global/Badge.vue +31 -0
  25. package/lib/client/components/global/CodeGroup.d.ts +5 -0
  26. package/lib/client/components/global/CodeGroup.js +107 -0
  27. package/lib/client/components/global/CodeGroupItem.vue +31 -0
  28. package/lib/{composables → client/composables}/index.d.ts +2 -0
  29. package/lib/{composables → client/composables}/index.js +2 -0
  30. package/lib/client/composables/useDarkMode.d.ts +12 -0
  31. package/lib/client/composables/useDarkMode.js +57 -0
  32. package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
  33. package/lib/{composables → client/composables}/useNavLink.js +0 -0
  34. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
  35. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +1 -1
  36. package/lib/client/composables/useScrollPromise.d.ts +6 -0
  37. package/lib/client/composables/useScrollPromise.js +14 -0
  38. package/lib/{composables → client/composables}/useSidebarItems.d.ts +12 -7
  39. package/lib/client/composables/useSidebarItems.js +120 -0
  40. package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
  41. package/lib/{composables → client/composables}/useThemeData.js +1 -1
  42. package/lib/client/index.d.ts +4 -0
  43. package/lib/client/index.js +2 -0
  44. package/lib/client/layouts/404.vue +25 -0
  45. package/lib/client/layouts/Layout.vue +128 -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 +21 -33
  53. package/lib/client/styles/custom-container.scss +88 -0
  54. package/lib/{styles → client/styles}/home.scss +27 -24
  55. package/lib/{styles → client/styles}/index.scss +4 -4
  56. package/lib/{styles → client/styles}/layout.scss +52 -35
  57. package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +37 -47
  58. package/lib/client/styles/navbar.scss +177 -0
  59. package/lib/client/styles/normalize.scss +172 -0
  60. package/lib/{styles → client/styles}/page.scss +15 -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/{utils → client/utils}/index.d.ts +1 -0
  67. package/lib/{utils → client/utils}/index.js +1 -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 +1 -1
  71. package/lib/{utils → client/utils}/resolveEditLink.js +14 -8
  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 +122 -0
  76. package/lib/node/index.d.ts +5 -5
  77. package/lib/node/index.js +10 -6
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
  79. package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +11 -9
  80. package/lib/node/utils/index.d.ts +2 -0
  81. package/lib/node/utils/index.js +18 -0
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
  83. package/lib/node/utils/resolveContainerPluginOptions.js +22 -0
  84. package/lib/{types → shared}/index.d.ts +0 -0
  85. package/lib/{types → shared}/index.js +5 -1
  86. package/lib/{types → shared}/nav.d.ts +11 -12
  87. package/lib/{types → shared}/nav.js +0 -0
  88. package/lib/{types → shared}/options.d.ts +42 -10
  89. package/lib/{types → shared}/options.js +0 -0
  90. package/lib/{types → shared}/page.d.ts +13 -5
  91. package/lib/{types → shared}/page.js +0 -0
  92. package/package.json +38 -29
  93. package/templates/build.html +33 -0
  94. package/CHANGELOG.md +0 -353
  95. package/lib/clientAppEnhance.js +0 -23
  96. package/lib/clientAppSetup.js +0 -11
  97. package/lib/components/DropdownLink.vue +0 -141
  98. package/lib/components/DropdownTransition.vue +0 -34
  99. package/lib/components/Home.vue +0 -133
  100. package/lib/components/NavLink.vue +0 -105
  101. package/lib/components/Navbar.vue +0 -113
  102. package/lib/components/Sidebar.vue +0 -38
  103. package/lib/components/SidebarChild.d.ts +0 -6
  104. package/lib/components/SidebarChild.js +0 -83
  105. package/lib/components/ToggleSidebarButton.vue +0 -27
  106. package/lib/components/global/Badge.vue +0 -37
  107. package/lib/components/global/CodeGroup.vue +0 -85
  108. package/lib/components/global/CodeGroupItem.vue +0 -25
  109. package/lib/components/global/OutboundLink.vue +0 -30
  110. package/lib/composables/useSidebarItems.js +0 -108
  111. package/lib/index.d.ts +0 -6
  112. package/lib/index.js +0 -67
  113. package/lib/layouts/404.vue +0 -38
  114. package/lib/layouts/Layout.vue +0 -132
  115. package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
  116. package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  117. package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
  118. package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
  119. package/lib/node/resolveContainerPluginOptions.js +0 -79
  120. package/lib/node/resolveGitPluginOptions.d.ts +0 -6
  121. package/lib/node/resolveGitPluginOptions.js +0 -22
  122. package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
  123. package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
  124. package/lib/styles/_normalize.scss +0 -148
  125. package/lib/styles/_variables.scss +0 -34
  126. package/lib/styles/custom-container.scss +0 -78
  127. package/lib/styles/navbar.scss +0 -140
  128. package/lib/styles/plugins.scss +0 -18
  129. package/lib/styles/sidebar.scss +0 -147
  130. package/lib/styles/sr-only.scss +0 -12
  131. package/lib/styles/transitions.scss +0 -13
  132. 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,105 +0,0 @@
1
- <template>
2
- <RouterLink
3
- v-if="isRouterLink"
4
- class="nav-link"
5
- :to="item.link"
6
- :exact="isExact"
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 { useSiteData } from '@vuepress/client'
34
- import { isLinkHttp, isLinkMailto, isLinkTel } from '@vuepress/shared'
35
- import type { NavLink } from '../types'
36
-
37
- export default defineComponent({
38
- name: 'NavLink',
39
-
40
- inheritAttrs: false,
41
-
42
- props: {
43
- item: {
44
- type: Object as PropType<NavLink>,
45
- required: true,
46
- },
47
- },
48
-
49
- setup(props) {
50
- const site = useSiteData()
51
- const { item } = toRefs(props)
52
-
53
- // if the link has http protocol
54
- const hasHttpProtocol = computed(() => isLinkHttp(item.value.link))
55
- // if the link has non-http protocol
56
- const hasNonHttpProtocal = computed(
57
- () => isLinkMailto(item.value.link) || isLinkTel(item.value.link)
58
- )
59
- // resolve the `target` attr
60
- const linkTarget = computed(() => {
61
- if (hasNonHttpProtocal.value) return null
62
- if (item.value.target) return item.value.target
63
- if (hasHttpProtocol.value) return '_blank'
64
- return null
65
- })
66
- // if the `target` attr is '_blank'
67
- const isBlankTarget = computed(() => linkTarget.value === '_blank')
68
- // is `<RouterLink>` or not
69
- const isRouterLink = computed(
70
- () =>
71
- !hasHttpProtocol.value &&
72
- !hasNonHttpProtocal.value &&
73
- !isBlankTarget.value
74
- )
75
- // is the `exact` prop of `<RouterLink>` should be true
76
- const isExact = computed(() => {
77
- const localeKeys = Object.keys(site.value.locales)
78
- if (localeKeys.length) {
79
- return localeKeys.some((key) => key === item.value.link)
80
- }
81
- return item.value.link === '/'
82
- })
83
- // resolve the `rel` attr
84
- const linkRel = computed(() => {
85
- if (hasNonHttpProtocal.value) return null
86
- if (item.value.rel) return item.value.rel
87
- if (isBlankTarget.value) return 'noopener noreferrer'
88
- return null
89
- })
90
- // resolve the `aria-label` attr
91
- const linkAriaLabel = computed(
92
- () => item.value.ariaLabel || item.value.text
93
- )
94
-
95
- return {
96
- isBlankTarget,
97
- isExact,
98
- isRouterLink,
99
- linkRel,
100
- linkTarget,
101
- linkAriaLabel,
102
- }
103
- },
104
- })
105
- </script>
@@ -1,113 +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 } 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
- 'max-width': 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
- }
102
- },
103
- })
104
-
105
- function getCssValue(el: HTMLElement | null, property: string): number {
106
- // NOTE: Known bug, will return 'auto' if style value is 'auto'
107
- const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
108
- property
109
- ]
110
- const num = Number.parseInt(val, 10)
111
- return Number.isNaN(num) ? 0 : num
112
- }
113
- </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">
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,83 +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 isActive = (route, target) => {
8
- if (target === undefined) {
9
- return false;
10
- }
11
- if (route.hash === target) {
12
- return true;
13
- }
14
- const currentPath = normalizePath(route.path);
15
- const targetPath = normalizePath(target);
16
- return currentPath === targetPath;
17
- };
18
- const renderItem = (item, props) => {
19
- // if the item has link, render it as `<NavLink>`
20
- if (item.link) {
21
- return h(NavLink, {
22
- ...props,
23
- item,
24
- });
25
- }
26
- // if the item only has text, render it as `<p>`
27
- return h('p', props, item.text);
28
- };
29
- const renderChildren = (item, depth) => {
30
- var _a;
31
- if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
32
- return null;
33
- }
34
- return h('ul', {
35
- class: {
36
- 'sidebar-sub-headers': depth > 0,
37
- },
38
- }, item.children.map((child) => h('li', h(SidebarChild, {
39
- item: child,
40
- depth: depth + 1,
41
- }))));
42
- };
43
- export const SidebarChild = ({ item, depth }) => {
44
- var _a;
45
- if (item.isGroup) {
46
- return [
47
- h('section', {
48
- class: {
49
- 'sidebar-group': true,
50
- },
51
- }, [
52
- renderItem(item, {
53
- class: 'sidebar-heading',
54
- }),
55
- renderChildren(item, depth),
56
- ]),
57
- ];
58
- }
59
- const route = useRoute();
60
- const active = isActive(route, item.link) ||
61
- ((_a = item.children) === null || _a === void 0 ? void 0 : _a.some((child) => isActive(route, child.link)));
62
- return [
63
- renderItem(item, {
64
- class: {
65
- 'sidebar-link': true,
66
- active,
67
- },
68
- }),
69
- renderChildren(item, depth),
70
- ];
71
- };
72
- SidebarChild.displayName = 'SidebarChild';
73
- SidebarChild.props = {
74
- item: {
75
- type: Object,
76
- required: true,
77
- },
78
- depth: {
79
- type: Number,
80
- required: false,
81
- default: 0,
82
- },
83
- };
@@ -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,85 +0,0 @@
1
- <script lang="ts">
2
- import { defineComponent, h, ref } from 'vue'
3
- import type { Component, VNode } from 'vue'
4
-
5
- export default defineComponent({
6
- name: 'CodeGroup',
7
-
8
- setup(_, { slots }) {
9
- // index of current active item
10
- const activeIndex = ref(-1)
11
-
12
- return () => {
13
- // NOTICE: here we put the `slots.default()` inside the render function to make
14
- // the slots reactive, otherwise the slot content won't be changed once the
15
- // `setup()` function of current component is called
16
-
17
- // get children code-group-item
18
- const items = (slots.default?.() || [])
19
- .filter((vnode) => (vnode.type as Component).name === 'CodeGroupItem')
20
- .map((vnode) => {
21
- if (vnode.props === null) {
22
- vnode.props = {}
23
- }
24
- return vnode as VNode & { props: Exclude<VNode['props'], null> }
25
- })
26
-
27
- // do not render anything if there is no code-group-item
28
- if (items.length === 0) {
29
- return null
30
- }
31
-
32
- if (activeIndex.value === -1) {
33
- // initial state
34
-
35
- // find the index of the code-group-item with `active` props
36
- activeIndex.value = items.findIndex(
37
- (vnode) => vnode.props.active === '' || vnode.props.active === true
38
- )
39
-
40
- // if there is no `active` props on code-group-item, set the first item active
41
- if (activeIndex.value === -1) {
42
- activeIndex.value = 0
43
- }
44
- } else {
45
- // re-render triggered by modifying `activeIndex` ref
46
-
47
- // set the active item
48
- items.forEach((vnode, i) => {
49
- vnode.props.active = i === activeIndex.value
50
- })
51
- }
52
-
53
- return h('div', { class: 'code-group' }, [
54
- h(
55
- 'div',
56
- { class: 'code-group__nav' },
57
- h(
58
- 'ul',
59
- { class: 'code-group__ul' },
60
- items.map((vnode, i) =>
61
- h(
62
- 'li',
63
- { class: 'code-group__li' },
64
- h(
65
- 'button',
66
- {
67
- class: `code-group__nav-tab${
68
- i === activeIndex.value
69
- ? ' code-group__nav-tab-active'
70
- : ''
71
- }`,
72
- onClick: () => (activeIndex.value = i),
73
- },
74
- vnode.props.title
75
- )
76
- )
77
- )
78
- )
79
- ),
80
- items,
81
- ])
82
- }
83
- },
84
- })
85
- </script>
@@ -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>