Skip to content

Commit

Permalink
docs: separate route path and link in api explorer nav item
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Sep 4, 2023
1 parent ccad8ec commit e2350a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/docs/src/components/app/list/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
href?: string
subfolder?: string
disabled?: boolean
routeMatch?: string
routePath?: string
}
function generateApiItems (locale: string) {
Expand All @@ -101,13 +103,19 @@
if (litem.subfolder) path = litem.subfolder
const route = routes.find((route: { path: string }) => route.path.endsWith(`/${locale}/${path}/${litem.title}/`))
const route = litem.routeMatch
? routes.find((route: { path: string }) => route.path.endsWith(`/${locale}/${path}/${litem.routeMatch}/`))
: routes.find((route: { path: string }) => route.path.endsWith(`/${locale}/${path}/${litem.title}/`))
const to = litem.routePath
? `/${locale}/${path}/${litem.routePath}/`
: route?.path
return {
title: route?.meta?.nav ?? route?.meta?.title ?? litem.title,
subtitle: litem.subtitle && te(litem.subtitle) ? t(litem.subtitle) : litem.subtitle,
emphasized: route?.meta?.emphasized ?? false,
to: route?.path,
to,
disabled: !route,
}
} else if (item.divider) {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/components/doc/Explorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}, [])
const name = route.params.name?.replace('/', '')
const pascalName = name && `${name.charAt(0).toUpperCase()}${camelize(name.slice(1))}`
const pascalName = name ? `${name.charAt(0).toUpperCase()}${camelize(name.slice(1))}` : undefined
const model = ref(components.some(v => v.value === name) ? name : pascalName)
const sections = ['props', 'events', 'slots', 'exposed', 'sass', 'options', 'argument', 'modifiers']
Expand Down
7 changes: 6 additions & 1 deletion packages/docs/src/data/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
"activeIcon": "mdi-view-dashboard",
"items": [
"all",
{ "title": "explorer", "subtitle": "browse-components" },
{
"title": "explorer",
"routeMatch": "explorer/:name(.*)",
"routePath": "explorer",
"subtitle": "browse-components"
},
{ "divider": true },
{ "subheader": "containment" },
"buttons",
Expand Down

0 comments on commit e2350a3

Please sign in to comment.