You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello developer, please have a quick look at this contributing guide before starting, you probably already know most of what's in here but it's a quick read and explains a few things that are custom to this project:
4
+
5
+
if you wish to contribute to this project, please first open a [ticket in the github issues page of this project](https://github.com/chrisweb/remark-table-of-contents/issues) and explain briefly what fix or improvement you want to provide (remember the github ticket number you will need it for the commit message later on)
6
+
7
+
go the [github page of this project](https://github.com/chrisweb/remark-table-of-contents) and hit the fork button
8
+
9
+
clone your fork so that you can edit the code in your local IDE (VSCode):
now you can open the project in your IDE (VSCode), happy coding...
14
+
15
+
when you are done coding, please first run the linting command `npm run lint`
16
+
17
+
then if there are no linting errors, create a new build using the `npm run build` command
18
+
19
+
now finally you can commit your local changes to your fork (if your commit is related to a ticket start your commit message with the "#TICKER_NUMBER", this will "link" the commit to the ticket)
20
+
21
+
`git commit -m "#TICKER_NUMBER commit message"`
22
+
23
+
now go to the github page of your fork and hit the pull request button to open a pull request from your fork to this projects github repository
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
56
+
Note: I have passed an option from **mdast-util-toc** to make the table of contents more compact, I also customized the container element by adding some attributes, for a full list of options check out the [options section](#options) below
57
57
58
58
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):
59
59
@@ -69,6 +69,8 @@ then create an mdx document, for example `app/articles/page.mdx` and add some co
69
69
%toc%
70
70
```
71
71
72
+
Note: right now the toc placeholder `%toc%` can not be inside of something else, for example if you put it inside of an html element then the plugin will not be able to find it, this could an improvement (PRs are welcome by the way 😉), other than that you can put the toc wherever you want and you can change the placeholder via the plugin options if you prefer some other string instead of the default one
73
+
72
74
the output will look like this:
73
75
74
76
```md
@@ -80,25 +82,29 @@ the output will look like this:
*`options.mdx` (`boolean`, default: true) if you use mdx-js leave it to true, if you use markdown set it to false
96
-
*`options.containerTagName` (`string`, default: 'aside') chose an element for the container that is around the toc, can by any html element you want, a `div`, a `section` ...
97
-
*`options.hasContainer` (`boolean`, default: true) by default the toc is in a container, set to false to not use a container
98
-
99
-
let's the plugin know if you are using mdx (mdx:true) or markdown (mdx: false)
99
+
all options have default values which for most use cases should be enough, meaning there is zero configuration to do, unless you want to customize something
100
100
101
-
`options.*`
101
+
*`mdx` (`boolean`, default: true) if you use mdx-js leave it to true, if you use markdown set it to false
102
+
*`placeholder` (`string`, default '%toc%') the placeholder that you insert into your markdown / MDX and that will get replaced by the toc
103
+
*`hasContainer` (`boolean`, default: true) by default the toc is in a container (by default it is an `<aside>` element, see next option), set to false to not use a container
104
+
*`containerTagName` (`string`, default: 'aside') chose an element for the container that is around the toc, can by any html element you want, a `div`, a `section` ...
105
+
*`containerAttributes` (`object`, default {}) an object, where the keys are the attribute names and the values are the attribute values, allows you for example to add an `id` html attribute or a `class` attribute where the value is an array of class names
106
+
*`hasNav` (`boolean`, default: true) by default the toc is inside a `<nav>` element, set to false to not use the nav element
107
+
*`navAttributes` (`object`, default {}) an object, where the keys are the attribute names and the values are the attribute values, allows you for example to add an `id` html attribute or a `class` attribute where the value is an array of class names
102
108
103
109
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:
104
110
@@ -112,6 +118,10 @@ this plugin uses [mdast-util-toc](https://github.com/syntax-tree/mdast-util-toc)
112
118
113
119
## TODOs
114
120
115
-
* add a nav element around the toc, make it optional (or container could be one or more elements? probably more difficult to validate)
116
-
* make the placeholder string customizable so that it can be changed to whatever string the dev wants to use
117
-
* add an option to be able to set a class on the container (or allow any attributes?)
121
+
* right now the toc placeholder can not be inside of something, for example if you put it into an html element then the plugin won't find the placeholder, maybe replacing my simple search with [unist-util-visit](https://www.npmjs.com/package/unist-util-visit) could allow devs to put the toc inside whatever they want!?
122
+
123
+
## contributing
124
+
125
+
PRs are welcome 😉
126
+
127
+
To get started, please check out the [CONTRIBUTING.md](CONTRIBUTING.md) guide of this project
0 commit comments