Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 6b0a52f

Browse files
committed
docs: move getRoutes to utils
1 parent e20d8a7 commit 6b0a52f

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

website/src/docs-theme/components/MobileNav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useColorModeValue } from '@chakra-ui/vue-next'
44
import { useRoute } from 'vue-router'
55
import { useLockScroll } from 'vue-composable'
66
import { SidebarContent } from '../components/Sidebar/AppSidebar.vue'
7-
import { getRoutes } from '../layout/LayoutMdx.vue'
7+
import { getRoutes } from '../utils/get-routes'
88
99
export const MobileNavButton = (props: any, { slots }: SetupContext) => (
1010
<c-icon-button

website/src/docs-theme/layout/LayoutMdx.vue

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,10 @@
99

1010
<script lang="ts">
1111
import { defineComponent, PropType } from 'vue'
12-
import docsSidebar from '@/config/docs-sidebar.json'
13-
import guidesSidebar from '@/config/guides-sidebar.json'
14-
import blogSidebar from '@/config/blog-sidebar.json'
1512
import { getHeadings } from '@/docs-theme/utils/get-headings'
13+
import { getRoutes } from '@/docs-theme/utils/get-routes'
1614
import { useRoute } from 'vue-router'
1715
18-
export function getRoutes(slug: string) {
19-
// for home page, use docs sidebat
20-
if (slug === '/') return docsSidebar.routes
21-
22-
const configMap = {
23-
'/resources': docsSidebar,
24-
'/changelog': docsSidebar,
25-
'/guides': guidesSidebar,
26-
'/blog': blogSidebar,
27-
'/docs': docsSidebar,
28-
}
29-
30-
const [_path, sidebar] =
31-
Object.entries(configMap).find(([path, _sidebar]) =>
32-
slug.startsWith(path)
33-
) ?? []
34-
35-
return sidebar?.routes ?? []
36-
}
37-
3816
export default defineComponent({
3917
props: {
4018
frontmatter: {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import docsSidebar from '@/config/docs-sidebar.json'
2+
import guidesSidebar from '@/config/guides-sidebar.json'
3+
import blogSidebar from '@/config/blog-sidebar.json'
4+
5+
export function getRoutes(slug: string) {
6+
// for home page, use docs sidebat
7+
if (slug === '/') return docsSidebar.routes
8+
9+
const configMap = {
10+
'/resources': docsSidebar,
11+
'/changelog': docsSidebar,
12+
'/guides': guidesSidebar,
13+
'/blog': blogSidebar,
14+
'/docs': docsSidebar,
15+
}
16+
17+
const [_path, sidebar] =
18+
Object.entries(configMap).find(([path, _sidebar]) =>
19+
slug.startsWith(path)
20+
) ?? []
21+
22+
return sidebar?.routes ?? []
23+
}

0 commit comments

Comments
 (0)