Skip to content

Commit

Permalink
example with options
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed Jun 23, 2023
1 parent 1ecbe38 commit d2c761c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const nextConfig = (/*phase*/) => {
const withMDX = WithMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkTableOfContents],
remarkPlugins: [[remarkTableOfContents, { tight: true }]],
rehypePlugins: [],
},
})
Expand All @@ -53,6 +53,8 @@ const nextConfig = (/*phase*/) => {
export default nextConfig
```

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

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):

```md
Expand Down Expand Up @@ -90,13 +92,13 @@ the output will look like this:

`options` (optional)

`options.mdx` (boolean, default: true)
`options.mdx` (`boolean`, default: true)

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

`options.*`

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:
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:

* `heading` (`string`, optional) heading to look for, wrapped in `new RegExp('^(' + value + ')$', 'i')`
* `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, `###`)
Expand Down

0 comments on commit d2c761c

Please sign in to comment.