Skip to content

Commit babb09a

Browse files
authored
Merge pull request #190 from timlrx/fix/toc-slugs
Fix TOC slug initialisation
2 parents a76e92c + 5dfaf6a commit babb09a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changeset/heavy-dolls-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'pliny': patch
3+
---
4+
5+
fix toc slugs are tracked across documents

packages/pliny/src/mdx-plugins/remark-toc-headings.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import GithubSlugger from 'github-slugger'
66
import { toString } from 'mdast-util-to-string'
77
import { remark } from 'remark'
88

9-
const slugger = new GithubSlugger()
10-
119
export type TocItem = {
1210
value: string
1311
url: string
@@ -20,6 +18,7 @@ export type Toc = TocItem[]
2018
* Extracts TOC headings from markdown file and adds it to the file's data object.
2119
*/
2220
export function remarkTocHeadings() {
21+
const slugger = new GithubSlugger()
2322
return (tree: Parent, file: VFile) => {
2423
const toc: Toc = []
2524
visit(tree, 'heading', (node: Heading) => {

0 commit comments

Comments
 (0)