add option to skip rendering child when rendering ToC#439
Merged
jamescarr28 merged 5 commits intomainfrom Mar 5, 2026
Merged
Conversation
ahickmann-gds
approved these changes
Feb 23, 2026
Contributor
|
So the code looks good to me, @NathanD-GDS you raised the initial bug, you wanna give this a look too? |
claire-cheuk
previously approved these changes
Mar 3, 2026
Needs final approval from Huw and Nathan before merging
NathanD-GDS
reviewed
Mar 4, 2026
NathanD-GDS
left a comment
There was a problem hiding this comment.
Looks good - just a few small suggestions.
README.md
Outdated
| ``` | ||
|
|
||
|
|
||
| This gem has helper functions to render your ToC. You should use: |
There was a problem hiding this comment.
Suggested change
| This gem has helper functions to render your ToC. You should use: | |
| This gem has helper functions to render your ToC. You can use: |
Is it 'should' or 'can'?
Contributor
Author
There was a problem hiding this comment.
Interesting question, it depends on how much leeway we want the gem to have I guess. I'd say that it's should as we're saying, 'if you want to [create a single page table of contents], you should use [the function] as we've tested it and approved it works in the style we expect'
huwd
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What’s changed
We have added an optional flag for the
multi_page_table_of_contents/render_page_treehelper functions. The table of contents (ToC) currently has limitations when using layouts to group sections and create filtered ToC - e.g. when usingheader_linksand requiring a specific ToC .Example usage
Identifying a user need
This is particularly an issue when we have a directory with an index page, and then sub directories containing nested sections. When trying to organise this structure using
header_linksto create sections, we want each section to create it's own ToC eg:The expected result would be:
This bug has been previously raised here. We are currently unable to publish updated public facing documentation due to the navigation being too painful. This fix allows us to do this, while maintaining backwards compatibility
Existing options that don't generate the right result
Using resource.children
If we use the resource.children call then we loose the section index page altogether. This page can only be found by clicking the link in the navigation (top right). This is a confusing user journey and very unclear.
code example:
Including resource in tree builder
If we try to include the the extra resource then the full child tree is rendered below the main section. Result below is the same if we merge into a single array etc
code example:
result:
Using single page ToC
When using the single page ToC functions the ToC changes when you move to a different page, with the section index missing altogether