Skip to content

Commit

Permalink
chore(docs): use native space to hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Sep 27, 2024
1 parent 16058b7 commit 4ce18c6
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions website/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,23 @@ const fixLinks = (sidebarMulti: SidebarMulti) => {
})
}

const fixTitles = (sidebarMulti: SidebarMulti) => {
return sidebarMultiVisitItems(sidebarMulti, (sidebarItem) => {
const [title, maybeHtml] = sidebarItem.text?.split('<') as [string, string | undefined]
if (sidebarItem.text) {
sidebarItem.text = title.replaceAll(/-/g, ' ').split(' ').join(' ')
+ (maybeHtml ? `<${maybeHtml}` : '')
}
})
}

/**
* @see https://vitepress-sidebar.cdget.com/guide/api
*/
const sidebars = fixTitles(fixLinks(generateSidebar([
const sidebars = fixLinks(generateSidebar([
{
scanStartPath: 'content/guides',
resolvePath: '/guides/',
prefixSeparator: '_',
removePrefixAfterOrdering: true,
useTitleFromFrontmatter: true,
useTitleFromFileHeading: true,
// https://github.com/jooy2/vitepress-sidebar/issues/176
// hyphenToSpace: true,
hyphenToSpace: true,
capitalizeEachWords: true,
keepMarkdownSyntaxFromTitle: true,
},
{
// hyphenToSpace: true,
hyphenToSpace: true,
capitalizeEachWords: true,
scanStartPath: 'content/examples',
resolvePath: '/examples/',
Expand All @@ -59,7 +48,7 @@ const sidebars = fixTitles(fixLinks(generateSidebar([
useTitleFromFileHeading: true,
keepMarkdownSyntaxFromTitle: true,
},
]) as SidebarMulti))
]) as SidebarMulti)

sidebars['/examples/'].items.find(_ => _.text === 'About')!.items!.unshift({ text: 'Introduction', link: '/' })
sidebars['/guides/'].items.unshift({ text: 'Introduction', link: '/' })
Expand Down

0 comments on commit 4ce18c6

Please sign in to comment.