Add Tables of Content(TOC) in SideBar

This commit is contained in:
chrox
2024-10-22 22:23:29 +02:00
parent 51f783be21
commit 8ab712bc0a
14 changed files with 293 additions and 82 deletions
+5 -3
View File
@@ -32,6 +32,10 @@ interface LanguageMap {
[key: string]: string;
}
interface Contributor {
name: LanguageMap;
}
const formatLanguageMap = (x: string | LanguageMap): string => {
if (!x) return '';
if (typeof x === 'string') return x;
@@ -41,7 +45,7 @@ const formatLanguageMap = (x: string | LanguageMap): string => {
const listFormat = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' });
const formatContributors = (contributors: any) =>
export const formatAuthors = (contributors: string | Contributor | [string | Contributor]) =>
Array.isArray(contributors)
? listFormat.format(
contributors.map((contributor) =>
@@ -51,5 +55,3 @@ const formatContributors = (contributors: any) =>
: typeof contributors === 'string'
? contributors
: formatLanguageMap(contributors?.name);
export const formatAuthors = (authors: any) => formatContributors(authors);