Skip to content

Commit

Permalink
docs(api-plugin): always gen entry / api-search
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Jul 13, 2023
1 parent 177b8d9 commit 051ed18
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/docs/build/api-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const localeList = locales
.map(item => item.alternate || item.locale)

function genApiLinks (componentName: string, header: string) {
const section = ['<entry />', '<api-search />']
const links = (Object.keys(pageToApi) as (keyof typeof pageToApi)[])
.filter(page => pageToApi[page].includes(componentName))
.reduce<string[]>((acc, href) => {
Expand All @@ -26,14 +27,9 @@ function genApiLinks (componentName: string, header: string) {
return acc
}, [])

if (!links.length || !header) return ''

const section = [
`## ${header} {#links}`,
links.join('\n'),
'<entry />',
'<api-search />',
]
if (links.length && header) {
section.unshift(...[links.join('\n'), `## ${header} {#links}`])
}

return `${section.join('\n\n')}\n\n`
}
Expand Down

0 comments on commit 051ed18

Please sign in to comment.