-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autogenerate table of contents for Docusaurus 2 #1549
Comments
Would recommend checking out MDX and see if they have first-class support for this - The docs is currently WIP but this might mean they've already built it out. |
but we still need custom plugin because our autogenerated_table_of_contents syntax is unique. Edit: the logic is unique too |
We'll change our syntax then. It's not too big of a deal to search and replace. This is a major update after all. |
Checked their source code. They don't have it. They are just manually typing Table of Contents. They recommend usinjg Remark-toc ## Table of Contents
## Bravo
### Charlie
## Delta become ## Table of Contents
- [Bravo](#bravo)
- [Charlie](#charlie)
- [Delta](#delta)
## Bravo
### Charlie
## Delta Docusaurus ## Options
<AUTOGENERATED_TABLE_OF_CONTENTS>
## Bravo
### Charlie
## Delta become ## Options
- [Bravo](#bravo)
- [Charlie](#charlie)
## Bravo
### Charlie
## Delta Ours is more of a partial TOC. But its indeed wrong to mark this as difficulty:starter. I'm going to assign myself It's also nicer to make it backward compatible as possible |
This is probably more suited for a future discussion, but would like to throw in an opinion that maybe we would like to consider the following two types of table of contents. Hoping @endiliey to consider these use cases when designing the API :)))) So that we can implement those variations as themes in the future.
This will be useful when the page content is rather rich and each page is relatively separate with one another
This counts as ToC because the headers of the extended section are the headers from that page's content. |
Sorry for the confusion. We actually have two types of toc. One is the right side User can swizzle Docitem and modify it as their wish, you can show the table of contents on the left, bottom or even inside the page. However this one is referring to another type of special syntax by Docusaurus. It is some kind of TOC, but more of a partial one. |
The overall TOC of the entire page on the right hand side is great!! I'd really love to see the ability to auto generate a partial TOC for a particular section only as shown by @endiliey in the above comment's last screenshot. I don't believe we can do that right now in V1. |
@amimas actually that's what See https://github.com/jaredpalmer/formik/blame/next/docs/api/withFormik.md#L65-L68 Result: |
Actually I find the current implementation a bit limited. Here's why and let me know what your thoughts are. Maybe it can be more flexible in V2.
|
@amimas you are right ! I just went to re-read https://github.com/facebook/Docusaurus/blob/1aa0ea1152b0133830d127d11b123fcea261deb4/packages/docusaurus-1.x/lib/core/toc.js#L60-L71 and it seems that it's what really happening under the hood. That feature was implemented way before i joined the team, so i'm not really sure of the intention. To keep backward compatibility, i'll implement it like v1 for this feature. Technically in v2 you can just write remark plugins to do this and pass it to the |
Or maybe we should really discuss. Whether to deprecate this weird behavior or not. Backward compatibility isn't the highest priority because we're doing major version after all. Since we allow passing remark plugins in v2, I am not even sure if we should add this to v2. I am more towards deprecating this Having two table of contents is strange. I wonder if having table of contents on the right side is actually enough? |
Since this will be part of a major upgrade, I would opt for doing the right
thing over preserving non-ideal backwards compatibility.
…On Fri, Jun 7, 2019, 9:17 AM Endi ***@***.***> wrote:
Or maybe we should really discuss. Whether to deprecate this weird
behavior or not. Backward compatibility isn't the highest priority because
we're doing major version after all.
Since we allow passing remark plugins in v2, I am not even sure if we
should add this too v2.
I am more towards deprecating this <AUTOGENERATED_TABLE_OF_CONTENTS> that
seems to be weird. It increases parsing time and slow down the build
process.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1549>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKBCHJZLMU3KHIWKTVB6BLPZKCZXANCNFSM4HSGVYZQ>
.
|
If we were to stick to industry standard, https://github.com/remarkjs/remark-toc is also another solution It adds a Table of Contents to a Markdown document. You can specify depth too (not just h2 or h3 like v1. Adding it to v2 is also as simple as passing remark plugins to v2 docs options. I'm going to close this issue out as I feel we should do the right thing. If there is a need for |
I personally think having an auto generated toc for the entire page like what we have in V1 is the right thing to do and it should be part of the core instead of removing it entirely in V2. The location of this overall TOC is subjective but I like the current implementation of having it on the right side out of the box; it gives a clear distinction between the right sidebar and the overall toc for a given page without cluttering the sidebar on the left side. The |
Its not removed, check https://v2.docusaurus.io The thing is, adding a feature like partial toc in markdown by default will slow down the markdown parsing time. For site like jest which has thousands of pages, it can increase dev time a lot (every seconds saved is valuable) It should be an opt-in, and anyway it can be added easily by adding few lines of code in your config. I know how to do it with remark-toc. Perhaps I will add that to documentation in the future when we release v2 and teach people about it. |
Will add to docs #1578
2019年6月8日 12:52 +0800、Endi <notifications@github.com>のメール:
… > I personally think having an auto generated toc for the entire page like what we have in V1 is the right thing to do and it should be part of the core instead of removing it entirely in V2
Its not removed, check https://v2.docusaurus.io
The thing is, adding a feature like partial toc in markdown by default will slow down the markdown parsing time. For site like jest which has thousands of pages, it can increase dev time a lot (every seconds saved is valuable)
It should be an opt-in, and anyway it can be added easily by adding few lines of code in your config. I know how to do it with remark-toc. Perhaps I will add that to documentation in the future when we release v2 and teach people about it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Did this get updated to docs ? @wgao19 I think we need to show its deprecated somehow |
I think simply pointing it to this issue for reasoning is more sensible since the conversation above can explain it well. |
Would it be possible to add some more instructions to the blurb at https://v2.docusaurus.io/docs/migrating-from-v1-to-v2/#remove-autogenerated_table_of_contents? It directed me to this issue but it's unclear to me how to add remark-toc to my "remarkPlugins" configuration (that's not in the default docosaurus.config.js - where do I put that key?) or use it. Any simple explanation or pointer to a simple example would be super appreciated. |
@endiliey Hi, I am want to to generate the toc of h4/h5/h6 ( h2 to h6) . Now just display the h2/h3. Is there any config parms to achive this feasure. |
inline table of contents inside md docs (full or partial) will be possible thanks to #3904 |
🚀 Feature
Have you read the Contributing Guidelines on issues?
yes
Motivation
In v1, we have
<AUTOGENERATED_TABLE_OF_CONTENTS>.
syntax that generates table of content for ushttps://docusaurus.io/docs/en/doc-markdown#generating-table-of-contents
However, we haven't implemented it back in v2 because we use MDX instead of remarkable now. If anyone from the community is interested to work on this, PR is welcome.
Requirement
<AUTOGENERATED_TABLE_OF_CONTENTS>.
to a generated list of table of contentLet's say this is our markdown file
The remark manual test could be
Result
The text was updated successfully, but these errors were encountered: