-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Headless: Change
remarkToc
to remarkHeading
- Loading branch information
Showing
11 changed files
with
56 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'next-docs-zeta': major | ||
--- | ||
|
||
**Change `remarkToc` to `remarkHeading`** | ||
|
||
The previous `remarkToc` plugin only extracts table of contents from documents, now it also adds the `id` property to all heading elements. | ||
|
||
```diff | ||
- import { remarkToc } from "next-docs-zeta/mdx-plugins" | ||
+ import { remarkHeading } from "next-docs-zeta/mdx-plugins" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
import type { Literal, RootContent } from 'mdast'; | ||
import { visit } from './unist-visit'; | ||
|
||
const textTypes = ['text', 'inlineCode', 'code']; | ||
import type { RootContent } from 'mdast'; | ||
|
||
export function flattenNode(node: RootContent): string { | ||
const p: string[] = []; | ||
if ('children' in node) | ||
return node.children.map((child) => flattenNode(child)).join(''); | ||
|
||
visit(node, textTypes, (child: Literal) => { | ||
p.push(child.value); | ||
}); | ||
if ('value' in node) return node.value; | ||
|
||
return p.join(''); | ||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters