@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.
Files changed (86) hide show
  1. package/package.json +45 -29
  2. package/CHANGELOG.md +0 -368
  3. package/lib/clientAppEnhance.d.ts +0 -3
  4. package/lib/clientAppEnhance.js +0 -30
  5. package/lib/clientAppSetup.d.ts +0 -2
  6. package/lib/clientAppSetup.js +0 -11
  7. package/lib/components/DropdownLink.vue +0 -141
  8. package/lib/components/DropdownTransition.vue +0 -34
  9. package/lib/components/Home.vue +0 -133
  10. package/lib/components/NavLink.vue +0 -115
  11. package/lib/components/Navbar.vue +0 -114
  12. package/lib/components/NavbarLinks.vue +0 -174
  13. package/lib/components/Page.vue +0 -30
  14. package/lib/components/PageMeta.vue +0 -139
  15. package/lib/components/PageNav.vue +0 -116
  16. package/lib/components/Sidebar.vue +0 -38
  17. package/lib/components/SidebarChild.d.ts +0 -6
  18. package/lib/components/SidebarChild.js +0 -91
  19. package/lib/components/ToggleSidebarButton.vue +0 -27
  20. package/lib/components/global/Badge.vue +0 -37
  21. package/lib/components/global/CodeGroup.d.ts +0 -5
  22. package/lib/components/global/CodeGroup.js +0 -52
  23. package/lib/components/global/CodeGroupItem.vue +0 -25
  24. package/lib/components/global/OutboundLink.vue +0 -30
  25. package/lib/composables/index.d.ts +0 -5
  26. package/lib/composables/index.js +0 -5
  27. package/lib/composables/useNavLink.d.ts +0 -9
  28. package/lib/composables/useNavLink.js +0 -15
  29. package/lib/composables/useResolveRouteWithRedirect.d.ts +0 -5
  30. package/lib/composables/useResolveRouteWithRedirect.js +0 -24
  31. package/lib/composables/useScrollPromise.d.ts +0 -6
  32. package/lib/composables/useScrollPromise.js +0 -14
  33. package/lib/composables/useSidebarItems.d.ts +0 -31
  34. package/lib/composables/useSidebarItems.js +0 -114
  35. package/lib/composables/useThemeData.d.ts +0 -4
  36. package/lib/composables/useThemeData.js +0 -3
  37. package/lib/index.d.ts +0 -6
  38. package/lib/index.js +0 -67
  39. package/lib/layouts/404.vue +0 -38
  40. package/lib/layouts/Layout.vue +0 -152
  41. package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
  42. package/lib/node/assignDefaultLocaleOptions.js +0 -56
  43. package/lib/node/index.d.ts +0 -5
  44. package/lib/node/index.js +0 -17
  45. package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  46. package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
  47. package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
  48. package/lib/node/resolveContainerPluginOptions.js +0 -79
  49. package/lib/node/resolveGitPluginOptions.d.ts +0 -6
  50. package/lib/node/resolveGitPluginOptions.js +0 -22
  51. package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
  52. package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
  53. package/lib/shim.d.ts +0 -5
  54. package/lib/styles/_normalize.scss +0 -148
  55. package/lib/styles/_variables.scss +0 -34
  56. package/lib/styles/_wrapper.scss +0 -15
  57. package/lib/styles/arrow.scss +0 -39
  58. package/lib/styles/badge.scss +0 -33
  59. package/lib/styles/code-group.scss +0 -62
  60. package/lib/styles/code.scss +0 -277
  61. package/lib/styles/custom-container.scss +0 -78
  62. package/lib/styles/dropdown.scss +0 -197
  63. package/lib/styles/home.scss +0 -160
  64. package/lib/styles/index.scss +0 -19
  65. package/lib/styles/layout.scss +0 -194
  66. package/lib/styles/navbar.scss +0 -141
  67. package/lib/styles/page.scss +0 -71
  68. package/lib/styles/plugins.scss +0 -18
  69. package/lib/styles/sidebar.scss +0 -152
  70. package/lib/styles/sr-only.scss +0 -12
  71. package/lib/styles/toc.scss +0 -5
  72. package/lib/styles/transitions.scss +0 -13
  73. package/lib/types/index.d.ts +0 -3
  74. package/lib/types/index.js +0 -15
  75. package/lib/types/nav.d.ts +0 -44
  76. package/lib/types/nav.js +0 -2
  77. package/lib/types/options.d.ts +0 -205
  78. package/lib/types/options.js +0 -2
  79. package/lib/types/page.d.ts +0 -32
  80. package/lib/types/page.js +0 -2
  81. package/lib/utils/index.d.ts +0 -2
  82. package/lib/utils/index.js +0 -2
  83. package/lib/utils/resolveEditLink.d.ts +0 -9
  84. package/lib/utils/resolveEditLink.js +0 -23
  85. package/lib/utils/resolveRepoType.d.ts +0 -2
  86. package/lib/utils/resolveRepoType.js +0 -10
@@ -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>
@@ -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,174 +0,0 @@
1
- <template>
2
- <nav v-if="navbarLinks.length" class="navbar-links">
3
- <div v-for="item in navbarLinks" :key="item.link" class="navbar-links-item">
4
- <template v-if="item.children">
5
- <DropdownLink :item="item" />
6
- </template>
7
-
8
- <template v-else>
9
- <NavLink :item="item" />
10
- </template>
11
- </div>
12
- </nav>
13
- </template>
14
-
15
- <script lang="ts">
16
- import { computed, defineComponent } from 'vue'
17
- import type { ComputedRef } from 'vue'
18
- import { useRouter } from 'vue-router'
19
- import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
20
- import { isString } from '@vuepress/shared'
21
- import { useNavLink, useThemeLocaleData } from '../composables'
22
- import type { NavbarItem, NavbarGroup, ResolvedNavbarItem } from '../types'
23
- import { resolveRepoType } from '../utils'
24
- import DropdownLink from './DropdownLink.vue'
25
- import NavLink from './NavLink.vue'
26
-
27
- /**
28
- * Get navbar config of select language dropdown
29
- */
30
- const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
31
- const router = useRouter()
32
- const routeLocale = useRouteLocale()
33
- const siteLocale = useSiteLocaleData()
34
- const themeLocale = useThemeLocaleData()
35
-
36
- return computed<ResolvedNavbarItem[]>(() => {
37
- const localePaths = Object.keys(siteLocale.value.locales)
38
- // do not display language selection dropdown if there is only one language
39
- if (localePaths.length < 2) {
40
- return []
41
- }
42
- const currentPath = router.currentRoute.value.path
43
- const currentFullPath = router.currentRoute.value.fullPath
44
-
45
- const languageDropdown: ResolvedNavbarItem = {
46
- text: themeLocale.value.selectLanguageText ?? 'unkown language',
47
- ariaLabel: themeLocale.value.selectLanguageAriaLabel ?? 'unkown language',
48
- children: localePaths.map((targetLocalePath) => {
49
- // target locale config of this langauge link
50
- const targetSiteLocale =
51
- siteLocale.value.locales?.[targetLocalePath] ?? {}
52
- const targetThemeLocale =
53
- themeLocale.value.locales?.[targetLocalePath] ?? {}
54
- const targetLang = `${targetSiteLocale.lang}`
55
-
56
- const text = targetThemeLocale.selectLanguageName ?? targetLang
57
- let link
58
-
59
- if (targetLang === siteLocale.value.lang) {
60
- // if the target language is current language
61
- // stay at current link
62
- link = currentFullPath
63
- } else {
64
- // if the target language is not current language
65
- // try to link to the corresponding page of current page
66
- // or fallback to homepage
67
- const targetLocalePage = currentPath.replace(
68
- routeLocale.value,
69
- targetLocalePath
70
- )
71
- if (
72
- router.getRoutes().some((item) => item.path === targetLocalePage)
73
- ) {
74
- link = targetLocalePage
75
- } else {
76
- link = targetThemeLocale.home ?? targetLocalePath
77
- }
78
- }
79
-
80
- return {
81
- text,
82
- link,
83
- }
84
- }),
85
- }
86
-
87
- return [languageDropdown]
88
- })
89
- }
90
-
91
- /**
92
- * Get navbar config of repository link
93
- */
94
- const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
95
- const themeLocale = useThemeLocaleData()
96
-
97
- const repo = computed(() => themeLocale.value.repo)
98
- const repoType = computed(() =>
99
- repo.value ? resolveRepoType(repo.value) : null
100
- )
101
-
102
- const repoLink = computed(() => {
103
- if (repoType.value === 'GitHub') {
104
- return `https://github.com/${repo.value}`
105
- }
106
- return repo.value
107
- })
108
-
109
- const repoLabel = computed(() => {
110
- if (!repoLink.value) return null
111
- if (themeLocale.value.repoLabel) return themeLocale.value.repoLabel
112
- if (repoType.value === null) return 'Source'
113
- return repoType.value
114
- })
115
-
116
- return computed(() => {
117
- if (!repoLink.value || !repoLabel.value) {
118
- return []
119
- }
120
-
121
- return [
122
- {
123
- text: repoLabel.value,
124
- link: repoLink.value,
125
- },
126
- ]
127
- })
128
- }
129
-
130
- const resolveNavbarItem = (
131
- item: NavbarItem | NavbarGroup | string
132
- ): ResolvedNavbarItem => {
133
- if (isString(item)) {
134
- return useNavLink(item)
135
- }
136
- if ((item as NavbarGroup).children) {
137
- return {
138
- ...item,
139
- children: (item as NavbarGroup).children.map(resolveNavbarItem),
140
- }
141
- }
142
- return item as ResolvedNavbarItem
143
- }
144
-
145
- const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
146
- const themeLocale = useThemeLocaleData()
147
- return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
148
- }
149
-
150
- export default defineComponent({
151
- name: 'NavbarLinks',
152
-
153
- components: {
154
- NavLink,
155
- DropdownLink,
156
- },
157
-
158
- setup() {
159
- const navbarConfig = useNavbarConfig()
160
- const navbarSelectLanguage = useNavbarSelectLanguage()
161
- const navbarRepo = useNavbarRepo()
162
-
163
- const navbarLinks = computed(() => [
164
- ...navbarConfig.value,
165
- ...navbarSelectLanguage.value,
166
- ...navbarRepo.value,
167
- ])
168
-
169
- return {
170
- navbarLinks,
171
- }
172
- },
173
- })
174
- </script>
@@ -1,30 +0,0 @@
1
- <template>
2
- <main class="page">
3
- <slot name="top" />
4
-
5
- <div class="theme-default-content">
6
- <Content />
7
- </div>
8
-
9
- <PageMeta />
10
-
11
- <PageNav />
12
-
13
- <slot name="bottom" />
14
- </main>
15
- </template>
16
-
17
- <script>
18
- import { defineComponent } from 'vue'
19
- import PageMeta from './PageMeta.vue'
20
- import PageNav from './PageNav.vue'
21
-
22
- export default defineComponent({
23
- name: 'Page',
24
-
25
- components: {
26
- PageMeta,
27
- PageNav,
28
- },
29
- })
30
- </script>