diff --git a/.changeset/heavy-dolls-search.md b/.changeset/heavy-dolls-search.md new file mode 100644 index 0000000..c751ab3 --- /dev/null +++ b/.changeset/heavy-dolls-search.md @@ -0,0 +1,5 @@ +--- +'pliny': patch +--- + +fix toc slugs are tracked across documents diff --git a/packages/pliny/src/mdx-plugins/remark-toc-headings.ts b/packages/pliny/src/mdx-plugins/remark-toc-headings.ts index 7076e47..543cb2c 100644 --- a/packages/pliny/src/mdx-plugins/remark-toc-headings.ts +++ b/packages/pliny/src/mdx-plugins/remark-toc-headings.ts @@ -6,8 +6,6 @@ import GithubSlugger from 'github-slugger' import { toString } from 'mdast-util-to-string' import { remark } from 'remark' -const slugger = new GithubSlugger() - export type TocItem = { value: string url: string @@ -20,6 +18,7 @@ export type Toc = TocItem[] * Extracts TOC headings from markdown file and adds it to the file's data object. */ export function remarkTocHeadings() { + const slugger = new GithubSlugger() return (tree: Parent, file: VFile) => { const toc: Toc = [] visit(tree, 'heading', (node: Heading) => {