vitepress 0.22.4 → 1.0.0-draft.3

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 (149) hide show
  1. package/client.d.ts +2 -3
  2. package/dist/client/app/components/ClientOnly.js +1 -1
  3. package/dist/client/app/index.js +1 -1
  4. package/dist/client/index.d.ts +5 -0
  5. package/dist/client/shared.js +1 -0
  6. package/dist/client/theme-default/Layout.vue +39 -180
  7. package/dist/client/theme-default/NotFound.vue +9 -8
  8. package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +127 -0
  9. package/dist/client/theme-default/components/VPBackdrop.vue +39 -0
  10. package/dist/client/theme-default/components/VPBox.vue +59 -0
  11. package/dist/client/theme-default/components/VPButton.vue +123 -0
  12. package/dist/client/theme-default/components/VPContent.vue +74 -0
  13. package/dist/client/theme-default/components/VPDoc.vue +173 -0
  14. package/dist/client/theme-default/components/VPDocFooter.vue +141 -0
  15. package/dist/client/theme-default/components/VPDocOutline.vue +108 -0
  16. package/dist/client/theme-default/components/VPFlyout.vue +149 -0
  17. package/dist/client/theme-default/components/VPFooter.vue +53 -0
  18. package/dist/client/theme-default/components/VPHero.vue +144 -0
  19. package/dist/client/theme-default/components/VPHome.vue +33 -0
  20. package/dist/client/theme-default/components/VPHomeFeatures.vue +96 -0
  21. package/dist/client/theme-default/components/VPHomeHero.vue +17 -0
  22. package/dist/client/theme-default/components/VPHomeSponsors.vue +93 -0
  23. package/dist/client/theme-default/components/VPLink.vue +37 -0
  24. package/dist/client/theme-default/components/VPLocalNav.vue +106 -0
  25. package/dist/client/theme-default/components/VPMenu.vue +79 -0
  26. package/dist/client/theme-default/components/VPMenuGroup.vue +35 -0
  27. package/dist/client/theme-default/components/VPMenuLink.vue +30 -0
  28. package/dist/client/theme-default/components/VPNav.vue +33 -0
  29. package/dist/client/theme-default/components/VPNavBar.vue +110 -0
  30. package/dist/client/theme-default/components/VPNavBarAppearance.vue +25 -0
  31. package/dist/client/theme-default/components/VPNavBarExtra.vue +107 -0
  32. package/dist/client/theme-default/components/VPNavBarHamburger.vue +79 -0
  33. package/dist/client/theme-default/components/VPNavBarMenu.vue +29 -0
  34. package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +18 -0
  35. package/dist/client/theme-default/components/VPNavBarMenuLink.vue +56 -0
  36. package/dist/client/theme-default/components/VPNavBarSearch.vue +269 -0
  37. package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
  38. package/dist/client/theme-default/components/VPNavBarTitle.vue +57 -0
  39. package/dist/client/theme-default/components/VPNavBarTranslations.vue +74 -0
  40. package/dist/client/theme-default/components/VPNavScreen.vue +100 -0
  41. package/dist/client/theme-default/components/VPNavScreenAppearance.vue +33 -0
  42. package/dist/client/theme-default/components/VPNavScreenMenu.vue +24 -0
  43. package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +118 -0
  44. package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +33 -0
  45. package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +35 -0
  46. package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +34 -0
  47. package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +14 -0
  48. package/dist/client/theme-default/components/VPNavScreenTranslations.vue +73 -0
  49. package/dist/client/theme-default/components/VPPage.vue +5 -0
  50. package/dist/client/theme-default/components/VPSidebar.vue +118 -0
  51. package/dist/client/theme-default/components/VPSidebarGroup.vue +44 -0
  52. package/dist/client/theme-default/components/VPSidebarLink.vue +57 -0
  53. package/dist/client/theme-default/components/VPSkipLink.vue +72 -0
  54. package/dist/client/theme-default/components/VPSocialLink.vue +63 -0
  55. package/dist/client/theme-default/components/VPSocialLinks.vue +27 -0
  56. package/dist/client/theme-default/components/VPSponsors.vue +77 -0
  57. package/dist/client/theme-default/components/VPSponsorsGrid.vue +32 -0
  58. package/dist/client/theme-default/components/VPSwitch.vue +66 -0
  59. package/dist/client/theme-default/components/VPSwitchAppearance.vue +74 -0
  60. package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +8 -0
  61. package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +8 -0
  62. package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +8 -0
  63. package/dist/client/theme-default/components/icons/{ArrowLeft.vue → VPIconArrowLeft.vue} +0 -0
  64. package/dist/client/theme-default/components/icons/{ArrowRight.vue → VPIconArrowRight.vue} +0 -0
  65. package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +5 -0
  66. package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +5 -0
  67. package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +5 -0
  68. package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +5 -0
  69. package/dist/client/theme-default/components/icons/VPIconDiscord.vue +5 -0
  70. package/dist/client/theme-default/components/icons/VPIconEdit.vue +6 -0
  71. package/dist/client/theme-default/components/icons/VPIconExternalLink.vue +13 -0
  72. package/dist/client/theme-default/components/icons/VPIconFacebook.vue +5 -0
  73. package/dist/client/theme-default/components/icons/VPIconGitHub.vue +5 -0
  74. package/dist/client/theme-default/components/icons/VPIconHeart.vue +5 -0
  75. package/dist/client/theme-default/components/icons/VPIconInstagram.vue +5 -0
  76. package/dist/client/theme-default/components/icons/VPIconLanguages.vue +9 -0
  77. package/dist/client/theme-default/components/icons/VPIconLinkedIn.vue +5 -0
  78. package/dist/client/theme-default/components/icons/VPIconMoon.vue +5 -0
  79. package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +7 -0
  80. package/dist/client/theme-default/components/icons/VPIconPlus.vue +5 -0
  81. package/dist/client/theme-default/components/icons/VPIconSlack.vue +5 -0
  82. package/dist/client/theme-default/components/icons/VPIconSun.vue +13 -0
  83. package/dist/client/theme-default/components/icons/VPIconTwitter.vue +5 -0
  84. package/dist/client/theme-default/components/icons/VPIconYouTube.vue +5 -0
  85. package/dist/client/theme-default/composables/edit-link.js +22 -0
  86. package/dist/client/theme-default/composables/flyout.js +40 -0
  87. package/dist/client/theme-default/composables/nav.js +27 -1
  88. package/dist/client/theme-default/composables/outline.js +112 -0
  89. package/dist/client/theme-default/composables/prev-next.js +18 -0
  90. package/dist/client/theme-default/composables/sidebar.js +57 -0
  91. package/dist/client/theme-default/composables/sponsor-grid.js +92 -0
  92. package/dist/client/theme-default/fonts/inter-cyrillic-ext.woff2 +0 -0
  93. package/dist/client/theme-default/fonts/inter-cyrillic.woff2 +0 -0
  94. package/dist/client/theme-default/fonts/inter-greek-ext.woff2 +0 -0
  95. package/dist/client/theme-default/fonts/inter-greek.woff2 +0 -0
  96. package/dist/client/theme-default/fonts/inter-latin-ext.woff2 +0 -0
  97. package/dist/client/theme-default/fonts/inter-latin.woff2 +0 -0
  98. package/dist/client/theme-default/fonts/inter-vietnamese.woff2 +0 -0
  99. package/dist/client/theme-default/index.js +8 -4
  100. package/dist/client/theme-default/styles/base.css +203 -0
  101. package/dist/client/theme-default/styles/fonts.css +67 -0
  102. package/dist/client/theme-default/styles/utils.css +9 -0
  103. package/dist/client/theme-default/styles/vars.css +291 -66
  104. package/dist/client/theme-default/styles/vp-doc.css +425 -0
  105. package/dist/client/theme-default/styles/vp-sponsor.css +86 -0
  106. package/dist/client/theme-default/support/sidebar.js +29 -0
  107. package/dist/client/theme-default/support/utils.js +62 -0
  108. package/dist/node/cli.js +3 -8
  109. package/dist/node/index.d.ts +121 -78
  110. package/dist/node/index.js +1 -1
  111. package/dist/node/{serve-3035f99b.js → serve-b5dc02b2.js} +11444 -1417
  112. package/package.json +24 -18
  113. package/types/default-theme.d.ts +114 -77
  114. package/types/shared.d.ts +11 -6
  115. package/dist/client/theme-default/components/AlgoliaSearchBox.vue +0 -188
  116. package/dist/client/theme-default/components/BuySellAds.vue +0 -152
  117. package/dist/client/theme-default/components/CarbonAds.vue +0 -99
  118. package/dist/client/theme-default/components/EditLink.vue +0 -38
  119. package/dist/client/theme-default/components/Home.vue +0 -31
  120. package/dist/client/theme-default/components/HomeFeatures.vue +0 -143
  121. package/dist/client/theme-default/components/HomeFooter.vue +0 -50
  122. package/dist/client/theme-default/components/HomeHero.vue +0 -161
  123. package/dist/client/theme-default/components/LastUpdated.vue +0 -60
  124. package/dist/client/theme-default/components/NavBar.vue +0 -60
  125. package/dist/client/theme-default/components/NavBarTitle.vue +0 -41
  126. package/dist/client/theme-default/components/NavDropdownLink.vue +0 -135
  127. package/dist/client/theme-default/components/NavDropdownLinkItem.vue +0 -76
  128. package/dist/client/theme-default/components/NavLink.vue +0 -61
  129. package/dist/client/theme-default/components/NavLinks.vue +0 -52
  130. package/dist/client/theme-default/components/NextAndPrevLinks.vue +0 -88
  131. package/dist/client/theme-default/components/Page.vue +0 -53
  132. package/dist/client/theme-default/components/PageFooter.vue +0 -44
  133. package/dist/client/theme-default/components/SideBar.vue +0 -60
  134. package/dist/client/theme-default/components/SideBarLink.js +0 -68
  135. package/dist/client/theme-default/components/SideBarLinks.vue +0 -12
  136. package/dist/client/theme-default/components/ToggleSideBarButton.vue +0 -46
  137. package/dist/client/theme-default/components/icons/OutboundLink.vue +0 -31
  138. package/dist/client/theme-default/composables/activeSidebarLink.js +0 -99
  139. package/dist/client/theme-default/composables/editLink.js +0 -49
  140. package/dist/client/theme-default/composables/navLink.js +0 -42
  141. package/dist/client/theme-default/composables/nextAndPrevLinks.js +0 -37
  142. package/dist/client/theme-default/composables/repo.js +0 -38
  143. package/dist/client/theme-default/composables/sideBar.js +0 -57
  144. package/dist/client/theme-default/styles/code.css +0 -299
  145. package/dist/client/theme-default/styles/custom-blocks.css +0 -76
  146. package/dist/client/theme-default/styles/layout.css +0 -236
  147. package/dist/client/theme-default/styles/sidebar-links.css +0 -107
  148. package/dist/client/theme-default/support/sideBar.js +0 -46
  149. package/dist/client/theme-default/utils.js +0 -63
@@ -1,60 +0,0 @@
1
- <script setup lang="ts">
2
- import NavLinks from './NavLinks.vue'
3
- import SideBarLinks from './SideBarLinks.vue'
4
-
5
- defineProps<{ open: boolean }>()
6
- </script>
7
-
8
- <template>
9
- <aside class="sidebar" :class="{ open }">
10
- <NavLinks class="nav" />
11
-
12
- <slot name="sidebar-top" />
13
-
14
- <SideBarLinks />
15
-
16
- <slot name="sidebar-bottom" />
17
- </aside>
18
- </template>
19
-
20
- <style scoped>
21
- .sidebar {
22
- position: fixed;
23
- top: var(--header-height);
24
- bottom: 0;
25
- left: 0;
26
- z-index: var(--z-index-sidebar);
27
- border-right: 1px solid var(--c-divider);
28
- width: 16.4rem;
29
- background-color: var(--c-bg);
30
- overflow-y: auto;
31
- transform: translateX(-100%);
32
- transition: transform 0.25s ease;
33
- }
34
-
35
- @media (min-width: 720px) {
36
- .sidebar {
37
- transform: translateX(0);
38
- }
39
- }
40
-
41
- @media (min-width: 960px) {
42
- .sidebar {
43
- width: 20rem;
44
- }
45
- }
46
-
47
- .sidebar.open {
48
- transform: translateX(0);
49
- }
50
-
51
- .nav {
52
- display: block;
53
- }
54
-
55
- @media (min-width: 720px) {
56
- .nav {
57
- display: none;
58
- }
59
- }
60
- </style>
@@ -1,68 +0,0 @@
1
- import { h } from 'vue';
2
- import { useRoute, useData } from 'vitepress';
3
- import { joinUrl, isActive } from '../utils';
4
- export const SideBarLink = (props) => {
5
- const route = useRoute();
6
- const { site, frontmatter } = useData();
7
- const depth = props.depth || 1;
8
- const maxDepth = frontmatter.value.sidebarDepth || Infinity;
9
- const headers = route.data.headers;
10
- const text = props.item.text;
11
- const link = resolveLink(site.value.base, props.item.link);
12
- const children = props.item.children;
13
- const active = isActive(route, props.item.link);
14
- const childItems = depth < maxDepth
15
- ? createChildren(active, children, headers, depth + 1)
16
- : null;
17
- return h('li', { class: 'sidebar-link' }, [
18
- h(link ? 'a' : 'p', {
19
- class: { 'sidebar-link-item': true, active },
20
- href: link
21
- }, text),
22
- childItems
23
- ]);
24
- };
25
- function resolveLink(base, path) {
26
- if (path === undefined) {
27
- return path;
28
- }
29
- // keep relative hash to the same page
30
- if (path.startsWith('#')) {
31
- return path;
32
- }
33
- return joinUrl(base, path);
34
- }
35
- function createChildren(active, children, headers, depth = 1) {
36
- if (children && children.length > 0) {
37
- return h('ul', { class: 'sidebar-links' }, children.map((c) => {
38
- return h(SideBarLink, { item: c, depth });
39
- }));
40
- }
41
- return active && headers
42
- ? createChildren(false, resolveHeaders(headers), undefined, depth)
43
- : null;
44
- }
45
- function resolveHeaders(headers) {
46
- return mapHeaders(groupHeaders(headers));
47
- }
48
- function groupHeaders(headers) {
49
- headers = headers.map((h) => Object.assign({}, h));
50
- let lastH2;
51
- headers.forEach((h) => {
52
- if (h.level === 2) {
53
- lastH2 = h;
54
- }
55
- else if (lastH2) {
56
- ;
57
- (lastH2.children || (lastH2.children = [])).push(h);
58
- }
59
- });
60
- return headers.filter((h) => h.level === 2);
61
- }
62
- function mapHeaders(headers) {
63
- return headers.map((header) => ({
64
- text: header.title,
65
- link: `#${header.slug}`,
66
- children: header.children ? mapHeaders(header.children) : undefined
67
- }));
68
- }
@@ -1,12 +0,0 @@
1
- <script setup lang="ts">
2
- import { useSideBar } from '../composables/sideBar'
3
- import { SideBarLink } from './SideBarLink'
4
-
5
- const items = useSideBar()
6
- </script>
7
-
8
- <template>
9
- <ul v-if="items.length > 0" class="sidebar-links">
10
- <SideBarLink v-for="item of items" :item="item" />
11
- </ul>
12
- </template>
@@ -1,46 +0,0 @@
1
- <script lang="ts">
2
- export default {
3
- emits: ['toggle']
4
- }
5
- </script>
6
-
7
- <template>
8
- <div class="sidebar-button" @click="$emit('toggle')">
9
- <svg
10
- class="icon"
11
- xmlns="http://www.w3.org/2000/svg"
12
- aria-hidden="true"
13
- role="img"
14
- viewBox="0 0 448 512"
15
- >
16
- <path
17
- fill="currentColor"
18
- 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"
19
- class
20
- />
21
- </svg>
22
- </div>
23
- </template>
24
-
25
- <style>
26
- .sidebar-button {
27
- position: absolute;
28
- top: 0.6rem;
29
- left: 1rem;
30
- display: none;
31
- padding: 0.6rem;
32
- cursor: pointer;
33
- }
34
-
35
- .sidebar-button .icon {
36
- display: block;
37
- width: 1.25rem;
38
- height: 1.25rem;
39
- }
40
-
41
- @media screen and (max-width: 719px) {
42
- .sidebar-button {
43
- display: block;
44
- }
45
- }
46
- </style>
@@ -1,31 +0,0 @@
1
- <template>
2
- <svg
3
- class="icon outbound"
4
- xmlns="http://www.w3.org/2000/svg"
5
- aria-hidden="true"
6
- x="0px"
7
- y="0px"
8
- viewBox="0 0 100 100"
9
- width="15"
10
- height="15"
11
- >
12
- <path
13
- fill="currentColor"
14
- d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"
15
- />
16
- <polygon
17
- fill="currentColor"
18
- points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"
19
- />
20
- </svg>
21
- </template>
22
-
23
- <style>
24
- .icon.outbound {
25
- position: relative;
26
- top: -1px;
27
- display: inline-block;
28
- vertical-align: middle;
29
- color: var(--c-text-lighter);
30
- }
31
- </style>
@@ -1,99 +0,0 @@
1
- import { onMounted, onUnmounted, onUpdated } from 'vue';
2
- export function useActiveSidebarLinks() {
3
- let rootActiveLink = null;
4
- let activeLink = null;
5
- const onScroll = throttleAndDebounce(setActiveLink, 300);
6
- function setActiveLink() {
7
- const sidebarLinks = getSidebarLinks();
8
- const anchors = getAnchors(sidebarLinks);
9
- for (let i = 0; i < anchors.length; i++) {
10
- const anchor = anchors[i];
11
- const nextAnchor = anchors[i + 1];
12
- const [isActive, hash] = isAnchorActive(i, anchor, nextAnchor);
13
- if (isActive) {
14
- history.replaceState(null, document.title, hash ? hash : ' ');
15
- activateLink(hash);
16
- return;
17
- }
18
- }
19
- }
20
- function activateLink(hash) {
21
- deactiveLink(activeLink);
22
- deactiveLink(rootActiveLink);
23
- activeLink = document.querySelector(`.sidebar a[href="${hash}"]`);
24
- if (!activeLink) {
25
- return;
26
- }
27
- activeLink.classList.add('active');
28
- // also add active class to parent h2 anchors
29
- const rootLi = activeLink.closest('.sidebar-links > ul > li');
30
- if (rootLi && rootLi !== activeLink.parentElement) {
31
- rootActiveLink = rootLi.querySelector('a');
32
- rootActiveLink && rootActiveLink.classList.add('active');
33
- }
34
- else {
35
- rootActiveLink = null;
36
- }
37
- }
38
- function deactiveLink(link) {
39
- link && link.classList.remove('active');
40
- }
41
- onMounted(() => {
42
- setActiveLink();
43
- window.addEventListener('scroll', onScroll);
44
- });
45
- onUpdated(() => {
46
- // sidebar update means a route change
47
- activateLink(decodeURIComponent(location.hash));
48
- });
49
- onUnmounted(() => {
50
- window.removeEventListener('scroll', onScroll);
51
- });
52
- }
53
- function getSidebarLinks() {
54
- return [].slice.call(document.querySelectorAll('.sidebar a.sidebar-link-item'));
55
- }
56
- function getAnchors(sidebarLinks) {
57
- return [].slice
58
- .call(document.querySelectorAll('.header-anchor'))
59
- .filter((anchor) => sidebarLinks.some((sidebarLink) => sidebarLink.hash === anchor.hash));
60
- }
61
- function getPageOffset() {
62
- return document.querySelector('.nav-bar').offsetHeight;
63
- }
64
- function getAnchorTop(anchor) {
65
- const pageOffset = getPageOffset();
66
- return anchor.parentElement.offsetTop - pageOffset - 15;
67
- }
68
- function isAnchorActive(index, anchor, nextAnchor) {
69
- const scrollTop = window.scrollY;
70
- if (index === 0 && scrollTop === 0) {
71
- return [true, null];
72
- }
73
- if (scrollTop < getAnchorTop(anchor)) {
74
- return [false, null];
75
- }
76
- if (!nextAnchor || scrollTop < getAnchorTop(nextAnchor)) {
77
- return [true, decodeURIComponent(anchor.hash)];
78
- }
79
- return [false, null];
80
- }
81
- function throttleAndDebounce(fn, delay) {
82
- let timeout;
83
- let called = false;
84
- return () => {
85
- if (timeout) {
86
- clearTimeout(timeout);
87
- }
88
- if (!called) {
89
- fn();
90
- called = true;
91
- setTimeout(() => {
92
- called = false;
93
- }, delay);
94
- }
95
- else {
96
- timeout = setTimeout(fn, delay);
97
- }
98
- };
99
- }
@@ -1,49 +0,0 @@
1
- import { computed } from 'vue';
2
- import { useData } from 'vitepress';
3
- import { endingSlashRE, isExternal } from '../utils';
4
- const bitbucketRE = /bitbucket.org/;
5
- export function useEditLink() {
6
- const { page, theme, frontmatter } = useData();
7
- const url = computed(() => {
8
- const { repo, docsDir = '', docsBranch = 'master', docsRepo = repo, editLinks } = theme.value;
9
- const showEditLink = frontmatter.value.editLink != null
10
- ? frontmatter.value.editLink
11
- : editLinks;
12
- const { relativePath } = page.value;
13
- if (!showEditLink || !relativePath || !repo) {
14
- return null;
15
- }
16
- return createUrl(repo, docsRepo, docsDir, docsBranch, relativePath);
17
- });
18
- const text = computed(() => {
19
- return theme.value.editLinkText || 'Edit this page';
20
- });
21
- return {
22
- url,
23
- text
24
- };
25
- }
26
- function createUrl(repo, docsRepo, docsDir, docsBranch, path) {
27
- return bitbucketRE.test(repo)
28
- ? createBitbucketUrl(repo, docsRepo, docsDir, docsBranch, path)
29
- : createGitHubUrl(repo, docsRepo, docsDir, docsBranch, path);
30
- }
31
- function createGitHubUrl(repo, docsRepo, docsDir, docsBranch, path) {
32
- const base = isExternal(docsRepo)
33
- ? docsRepo
34
- : `https://github.com/${docsRepo}`;
35
- return (base.replace(endingSlashRE, '') +
36
- `/edit` +
37
- `/${docsBranch}/` +
38
- (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
39
- path);
40
- }
41
- function createBitbucketUrl(repo, docsRepo, docsDir, docsBranch, path) {
42
- const base = isExternal(docsRepo) ? docsRepo : repo;
43
- return (base.replace(endingSlashRE, '') +
44
- `/src` +
45
- `/${docsBranch}/` +
46
- (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
47
- path +
48
- `?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`);
49
- }
@@ -1,42 +0,0 @@
1
- import { computed } from 'vue';
2
- import { useRoute, withBase } from 'vitepress';
3
- import { isExternal as isExternalCheck } from '../utils';
4
- export function useNavLink(item) {
5
- const route = useRoute();
6
- const isExternal = isExternalCheck(item.value.link);
7
- const props = computed(() => {
8
- const routePath = normalizePath(`/${route.data.relativePath}`);
9
- let active = false;
10
- if (item.value.activeMatch) {
11
- active = new RegExp(item.value.activeMatch).test(routePath);
12
- }
13
- else {
14
- const itemPath = normalizePath(item.value.link);
15
- active =
16
- itemPath === '/'
17
- ? itemPath === routePath
18
- : routePath.startsWith(itemPath);
19
- }
20
- return {
21
- class: {
22
- active,
23
- isExternal
24
- },
25
- href: isExternal ? item.value.link : withBase(item.value.link),
26
- target: item.value.target || (isExternal ? `_blank` : null),
27
- rel: item.value.rel || (isExternal ? `noopener noreferrer` : null),
28
- 'aria-label': item.value.ariaLabel
29
- };
30
- });
31
- return {
32
- props,
33
- isExternal
34
- };
35
- }
36
- function normalizePath(path) {
37
- return path
38
- .replace(/#.*$/, '')
39
- .replace(/\?.*$/, '')
40
- .replace(/\.(html|md)$/, '')
41
- .replace(/\/index$/, '/');
42
- }
@@ -1,37 +0,0 @@
1
- import { computed } from 'vue';
2
- import { useData } from 'vitepress';
3
- import { isArray, ensureStartingSlash, removeExtention } from '../utils';
4
- import { getSideBarConfig, getFlatSideBarLinks } from '../support/sideBar';
5
- export function useNextAndPrevLinks() {
6
- const { page, theme } = useData();
7
- const path = computed(() => {
8
- return removeExtention(ensureStartingSlash(page.value.relativePath));
9
- });
10
- const candidates = computed(() => {
11
- const config = getSideBarConfig(theme.value.sidebar, path.value);
12
- return isArray(config) ? getFlatSideBarLinks(config) : [];
13
- });
14
- const index = computed(() => {
15
- return candidates.value.findIndex((item) => {
16
- return item.link === path.value;
17
- });
18
- });
19
- const next = computed(() => {
20
- if (theme.value.nextLinks !== false &&
21
- index.value > -1 &&
22
- index.value < candidates.value.length - 1) {
23
- return candidates.value[index.value + 1];
24
- }
25
- });
26
- const prev = computed(() => {
27
- if (theme.value.prevLinks !== false && index.value > 0) {
28
- return candidates.value[index.value - 1];
29
- }
30
- });
31
- const hasLinks = computed(() => !!next.value || !!prev.value);
32
- return {
33
- next,
34
- prev,
35
- hasLinks
36
- };
37
- }
@@ -1,38 +0,0 @@
1
- import { computed } from 'vue';
2
- import { useData } from 'vitepress';
3
- import { EXTERNAL_URL_RE } from '../../shared';
4
- export const platforms = ['GitHub', 'GitLab', 'Bitbucket'].map((platform) => {
5
- return [platform, new RegExp(platform, 'i')];
6
- });
7
- export function useRepo() {
8
- const { site } = useData();
9
- return computed(() => {
10
- const theme = site.value.themeConfig;
11
- const name = theme.docsRepo || theme.repo;
12
- if (!name) {
13
- return null;
14
- }
15
- const link = getRepoUrl(name);
16
- const text = getRepoText(link, theme.repoLabel);
17
- return { text, link };
18
- });
19
- }
20
- function getRepoUrl(repo) {
21
- // if the full url is not provided, default to GitHub repo
22
- return EXTERNAL_URL_RE.test(repo) ? repo : `https://github.com/${repo}`;
23
- }
24
- function getRepoText(url, text) {
25
- if (text) {
26
- return text;
27
- }
28
- // if no label is provided, deduce it from the repo url
29
- const hosts = url.match(/^https?:\/\/[^/]+/);
30
- if (!hosts) {
31
- return 'Source';
32
- }
33
- const platform = platforms.find(([_p, re]) => re.test(hosts[0]));
34
- if (platform && platform[0]) {
35
- return platform[0];
36
- }
37
- return 'Source';
38
- }
@@ -1,57 +0,0 @@
1
- import { computed } from 'vue';
2
- import { useRoute, useData } from 'vitepress';
3
- import { useActiveSidebarLinks } from '../composables/activeSidebarLink';
4
- import { getSideBarConfig } from '../support/sideBar';
5
- export function useSideBar() {
6
- const route = useRoute();
7
- const { site } = useData();
8
- useActiveSidebarLinks();
9
- return computed(() => {
10
- // at first, we'll check if we can find the sidebar setting in frontmatter.
11
- const headers = route.data.headers;
12
- const frontSidebar = route.data.frontmatter.sidebar;
13
- const sidebarDepth = route.data.frontmatter.sidebarDepth;
14
- // if it's `false`, we'll just return an empty array here.
15
- if (frontSidebar === false) {
16
- return [];
17
- }
18
- // if it's `auto`, render headers of the current page
19
- if (frontSidebar === 'auto') {
20
- return resolveAutoSidebar(headers, sidebarDepth);
21
- }
22
- // now, there's no sidebar setting at frontmatter; let's see the configs
23
- const themeSidebar = getSideBarConfig(site.value.themeConfig.sidebar, route.data.relativePath);
24
- if (themeSidebar === false) {
25
- return [];
26
- }
27
- if (themeSidebar === 'auto') {
28
- return resolveAutoSidebar(headers, sidebarDepth);
29
- }
30
- return themeSidebar;
31
- });
32
- }
33
- function resolveAutoSidebar(headers, depth) {
34
- const ret = [];
35
- if (headers === undefined) {
36
- return [];
37
- }
38
- let lastH2 = undefined;
39
- headers.forEach(({ level, title, slug }) => {
40
- if (level - 1 > depth) {
41
- return;
42
- }
43
- const item = {
44
- text: title,
45
- link: `#${slug}`
46
- };
47
- if (level === 2) {
48
- lastH2 = item;
49
- ret.push(item);
50
- }
51
- else if (lastH2) {
52
- ;
53
- (lastH2.children || (lastH2.children = [])).push(item);
54
- }
55
- });
56
- return ret;
57
- }