Skip to content

Commit d2c761c

Browse files
committed
example with options
1 parent 1ecbe38 commit d2c761c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const nextConfig = (/*phase*/) => {
3030
const withMDX = WithMDX({
3131
extension: /\.mdx?$/,
3232
options: {
33-
remarkPlugins: [remarkTableOfContents],
33+
remarkPlugins: [[remarkTableOfContents, { tight: true }]],
3434
rehypePlugins: [],
3535
},
3636
})
@@ -53,6 +53,8 @@ const nextConfig = (/*phase*/) => {
5353
export default nextConfig
5454
```
5555

56+
Note: I have passed an option from **mdast-util-toc** to make the table of contents more compact, for a full list of options check out the [options section](#options) below
57+
5658
then create an mdx document, for example `app/articles/page.mdx` and add some content with headings and the **table of contents placeholder** (put the placeholder in the document, where you want the toc to be displayed, can be anywhere you want):
5759

5860
```md
@@ -90,13 +92,13 @@ the output will look like this:
9092

9193
`options` (optional)
9294

93-
`options.mdx` (boolean, default: true)
95+
`options.mdx` (`boolean`, default: true)
9496

9597
let's the plugin know if you are using mdx (mdx:true) or markdown (mdx: false)
9698

9799
`options.*`
98100

99-
this plugin uses [mdast-util-toc](https://github.com/syntax-tree/mdast-util-toc) to generate the toc, which means all **mdast-util-toc** options are supported:
101+
this plugin uses [mdast-util-toc](https://github.com/syntax-tree/mdast-util-toc) under the hood, to generate the toc, which means all **mdast-util-toc** options are supported as well:
100102

101103
* `heading` (`string`, optional) heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')`
102104
* `maxDepth` (`number`, default: `6`) maximum heading depth to include in the table of contents. This is inclusive: when set to `3`, level three headings are included (those with three hashes, `###`)

0 commit comments

Comments
 (0)