Skip to content

Commit

Permalink
Merge pull request #190 from timlrx/fix/toc-slugs
Browse files Browse the repository at this point in the history
Fix TOC slug initialisation
  • Loading branch information
timlrx authored Nov 2, 2024
2 parents a76e92c + 5dfaf6a commit babb09a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-dolls-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pliny': patch
---

fix toc slugs are tracked across documents
3 changes: 1 addition & 2 deletions packages/pliny/src/mdx-plugins/remark-toc-headings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand Down

0 comments on commit babb09a

Please sign in to comment.