feat: add collapseByDefault option to TableOfContents (closes )

This commit is contained in:
Jacky Zhao 2023-11-04 12:11:42 -07:00
parent a62a97c7ab
commit 101e9946bd
4 changed files with 9 additions and 3 deletions
quartz/plugins/transformers

View file

@ -8,12 +8,14 @@ export interface Options {
maxDepth: 1 | 2 | 3 | 4 | 5 | 6
minEntries: 1
showByDefault: boolean
collapseByDefault: boolean
}
const defaultOptions: Options = {
maxDepth: 3,
minEntries: 1,
showByDefault: true,
collapseByDefault: false,
}
interface TocEntry {
@ -54,6 +56,7 @@ export const TableOfContents: QuartzTransformerPlugin<Partial<Options> | undefin
...entry,
depth: entry.depth - highestDepth,
}))
file.data.collapseToc = opts.collapseByDefault
}
}
}
@ -66,5 +69,6 @@ export const TableOfContents: QuartzTransformerPlugin<Partial<Options> | undefin
declare module "vfile" {
interface DataMap {
toc: TocEntry[]
collapseToc: boolean
}
}