Skip to content

Commit

Permalink
Update vitepress
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Jan 27, 2023
1 parent 032b00d commit 148a91a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ storybook-static/
# Symbolic docroot
/web
.phpunit.result.cache

/packages/docs/.vitepress/dist/
/packages/docs/.vitepress/cache/
2 changes: 1 addition & 1 deletion packages/docs/.vitepress/theme/components/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import Theme from 'vitepress/client/theme-default';
import Theme from 'vitepress/theme';
import { useKBarHandler } from '@bytebase/vue-kbar';
const { Layout } = Theme;
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/.vitepress/theme/components/NavBarTitle.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useData } from 'vitepress';
import { useSidebar } from 'vitepress/client/theme-default/composables/sidebar.js';
import VPImage from 'vitepress/client/theme-default/components/VPImage.vue';
import { useSidebar } from 'vitepress/dist/client/theme-default/composables/sidebar.js';
import VPImage from 'vitepress/dist/client/theme-default/components/VPImage.vue';
import Badge from './Badge.vue';
const { site, theme } = useData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
import { withBase } from 'vitepress';
import Loader from './Loader.vue';
import ControlButton from './PreviewControlButton.vue';
import useObserver from '../composables/useObserver.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/.vitepress/theme/components/SidebarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import type { DefaultTheme } from 'vitepress/theme';
import { inject, unref, computed } from 'vue';
import { useData } from 'vitepress';
import { isActive } from 'vitepress/client/theme-default/support/utils';
import VPLink from 'vitepress/client/theme-default/components/VPLink.vue';
import { isActive } from 'vitepress/dist/client/theme-default/support/utils';
import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue';
const props = defineProps<{
item: DefaultTheme.SidebarItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { normalizeLink } from 'vitepress/client/theme-default/support/utils.js';
import { normalizeLink } from 'vitepress/dist/client/theme-default/support/utils.js';
const props = defineProps({
modules: Object,
Expand Down
31 changes: 16 additions & 15 deletions packages/docs/.vitepress/theme/composables/useAllLinks.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import type { Ref } from 'vue';
import { ref, unref } from 'vue';
import { useData, withBase } from 'vitepress';
import { withLeadingCharacters } from '@studiometa/js-toolkit';
import { useData, useRoute, useRouter, withBase } from 'vitepress';

interface Link {
text: string;
link: string;
parent?: Link;
root?: Link;
keywords?: string[];
}

interface VitepressLink {
text: string;
link?: string;
items?: VitepressLink[];
keywords?: string[];
}

/**
Expand All @@ -27,31 +28,31 @@ function addLinks(
root?: VitepressLink,
) {
if (item.link) {
let { text, link } = item;
link = withBase(link);
let { text, link, keywords = [] } = item;

if (!linksSet.has(text + link)) {
const newLink:Link = {
if (!linksSet.has(link)) {
const newLink: Link = {
text,
link: link,
link: withBase(link),
keywords,
};

if (parent) {
newLink.parent = {
text: parent.text,
link: withBase(parent.link)
}
link: parent.link ? withBase(parent.link) : undefined,
};
}

if (root) {
newLink.root = {
text: root.text,
link: withBase(root.link)
link: root.link ? withBase(root.link) : undefined,
};
}

links.value.push(newLink);
linksSet.add(text + link);
linksSet.add(link);
}
}

Expand All @@ -65,13 +66,13 @@ export function useAllLinks() {
const { nav, sidebar } = unref(theme);

const links = ref([]);
const linkSet = new Set<string>();
const linkSet = new Set();

nav.forEach((item) => addLinks(links, linkSet, item));

Object.entries(sidebar).forEach(([name, items]) => {
const parent = nav.find(navItem => name.startsWith(navItem.link));
items.forEach((link) => addLinks(links, linkSet, link, parent));
Object.entries(sidebar).forEach(([name, item]) => {
const parent = nav.find((item) => name.startsWith(item.link));
item.forEach((link) => addLinks(links, linkSet, link, parent));
});

return {
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/.vitepress/theme/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

:root {
--vp-c-divider-light: var(--vp-c-divider);
}

.focus\:ring-opacity-1:focus,
.hover\:ring-opacity-1:hover {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"tailwindcss": "^3.2.4",
"unplugin-icons": "^0.14.3",
"unplugin-vue-components": "^0.19.6",
"vitepress": "^1.0.0-alpha.4"
"vitepress": "^1.0.0-alpha.38"
}
}

0 comments on commit 148a91a

Please sign in to comment.