-
Notifications
You must be signed in to change notification settings - Fork 23
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
thoughts on ocular TOC generation #101
Comments
I am not quite sure what the proposal is.
FWIW, I will add a requirement: I'd like to be able to link in docs that are in multiple doc trees (rather than just in one The reason is that we are increasingly modularizing our repos with multiple code bases into monorepos with
We are collecting everything related to that module inside that folder, except the docs, and for big repos it gets hard to track and keep the docs correct when they are in deep subfolders in a different structure. |
those are just notes as I try to get the TOC generation to work.
than if we have to accommodate every arrangement of chapter / entries. For multiple trees, I don't recommend dropping table-of-contents. I just feel the TOC could instead be: [ and that the TOC component would only display entries for one tree at a time. It would definitely be possible to go from one documentation page to another, via a link, regardless of its tree. the tree distinction is only to display one TOC at a time. Alternatively we could add a tree field to entries with children and only display entries of the current trees. This tree business is a further development, while it would be necessary to convert some of the sites that's not something I want to have resolved now. |
Back to the generation of TOC in onCreateNode vs along the createPage calls.
However, I'm not able to find that node with subsequent graphQl queries. So I'm considering a third approach - back in onCreateNode. Right now, what happens is that we don't know the order in which nodes are created. It can be: when the J node is treated it assumes all M nodes have been already treated. What we can do instead is:
Finally, when an M node is treated AND a tocNode exists, then we can add the slug and the title information at the right places in the tocNode. So, at the end of this process, all nodes should have the required information regardless of the order |
closed with #103 |
those are my notes as I'm researching better TOC generation for ocular.
First, it makes no sense to have a chapter notion different from entries. they are functionally the same and they just complicate the graph.
(What we could have is a notion of tree in the TOC. in some "legacy" ocular sites (ie vis.academy) we have several independant TOCs ie you can't navigate from a page described in one TOC to the next. those trees all have different entries in the header menu (or elsewhere). That's a P1 though)
If we use the onCreateNode callback, we can access the TOC node as it's created and directly mutate it. The problem is that the function we'd use relies on a docNodes object, which is half populated by then.
The alternative is to work at the createPages level, where we execute a graphQl query. But then, we no longer have access to the TOC node / we can't mutate it directly.
However, we can have the same information as a result from that query. If we can access the TOC node then great, else we'd have to create a new node and pass it the relevant information.
The text was updated successfully, but these errors were encountered: