-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
91 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,57 @@ | ||
import { NavigationItem } from 'typedoc'; | ||
|
||
import { SidebarOptions } from './types'; | ||
import { PluginOptions } from './types'; | ||
|
||
export const getSidebarJson = ( | ||
navigation: NavigationItem, | ||
out: string, | ||
sidebar: SidebarOptions, | ||
options: PluginOptions, | ||
) => { | ||
const navJson: any = []; | ||
|
||
const getShortName = (title: string) => { | ||
const longTitle = title.split('.'); | ||
return longTitle[longTitle.length - 1]; | ||
}; | ||
|
||
navigation.children?.forEach((navigationItem) => { | ||
if (navigationItem.url && navigationItem.children?.length === 0) { | ||
const urlKey = navigationItem.url.replace('.md', ''); | ||
navJson.push([ | ||
urlKey === 'README' ? `/${out}/` : 'modules', | ||
navigationItem.title, | ||
]); | ||
} else { | ||
if (navigationItem.isLabel) { | ||
navJson.push({ | ||
title: navigationItem.title, | ||
children: navigationItem.children?.map((navItem) => { | ||
return [ | ||
getUrlKey(navItem.url), | ||
sidebar.fullNames ? navItem.title : getShortName(navItem.title), | ||
options.sidebar?.fullNames | ||
? navItem.title | ||
: getShortName(navItem.title), | ||
]; | ||
}), | ||
}); | ||
} else { | ||
navJson.push([ | ||
getUrlKey(navigationItem.url) === 'README' | ||
? `/${options.out}/` | ||
: `/${options.out}/modules`, | ||
navigationItem.title, | ||
]); | ||
} | ||
}); | ||
if (sidebar.parentCategory && sidebar.parentCategory !== 'none') { | ||
return [{ title: sidebar.parentCategory, children: navJson }]; | ||
if ( | ||
options.sidebar?.parentCategory && | ||
options.sidebar.parentCategory !== 'none' | ||
) { | ||
return [ | ||
{ | ||
title: options.sidebar.parentCategory, | ||
children: navJson, | ||
initialOpenGroupIndex: -1, | ||
collapsable: false, | ||
}, | ||
]; | ||
} | ||
|
||
return navJson; | ||
}; | ||
|
||
const getShortName = (title: string) => { | ||
const longTitle = title.split('.'); | ||
return longTitle[longTitle.length - 1]; | ||
}; | ||
|
||
const getUrlKey = (url: string) => { | ||
return url.replace('.md', ''); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import MarkdownTheme from 'typedoc-plugin-markdown/dist/theme'; | ||
import { Renderer } from 'typedoc/dist/lib/output/renderer'; | ||
|
||
export default class VuePressTheme extends MarkdownTheme { | ||
constructor(renderer: Renderer, basePath: string) { | ||
super(renderer, basePath); | ||
renderer.application.options.setValue('hideBreadcrumbs', true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters