diff --git a/src/components/widget/TOC.astro b/src/components/widget/TOC.astro index 7b4f2a1..1ef6e5f 100644 --- a/src/components/widget/TOC.astro +++ b/src/components/widget/TOC.astro @@ -1,23 +1,33 @@ --- import type { MarkdownHeading } from 'astro'; +import { siteConfig } from "../../config"; interface Props { class?: string headings: MarkdownHeading[] } -const { headings = [] } = Astro.props; +let { headings = [] } = Astro.props; // generate random headings, for testing -/* -for (let i = 0; i < 50; i++) { - headings.push({ - text: `Heading ${i + 1}`, - depth: Math.floor(Math.random() * 3) + 1, - slug: `heading-${i + 1}` - }) -} -*/ +// headings = [ +// { text: 'Heading 1', depth: 1, slug: 'heading-1' }, +// { text: 'Heading 2', depth: 2, slug: 'heading-2' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 2', depth: 2, slug: 'heading-2' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 1', depth: 1, slug: 'heading-1' }, +// { text: 'Heading 2', depth: 2, slug: 'heading-2' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 2', depth: 2, slug: 'heading-2' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// { text: 'Heading 3', depth: 3, slug: 'heading-3' }, +// ] let minDepth = 10; for (const heading of headings) { @@ -36,9 +46,11 @@ const removeTailingHash = (text: string) => { } let heading1Count = 1; + +const maxLevel = siteConfig.toc.depth; ---