Skip to content

[repo-assist] Add nested navigation categories via '/' in category front matter - #1337

Closed
github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/fix-issue-927-nested-categories-d3d27576c72ace27
Closed

github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/fix-issue-927-nested-categories-d3d27576c72ace27

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Closes #927

Summary

Adds support for one level of nested navigation categories using / as a separator in the category front-matter field:

---
category: Collections/Lists
categoryindex: 1
index: 2
---

This renders in the sidebar as:

Collections           ← .nav-header (parent)
  Arrays               ← .nav-sub-header
    - Pattern Matching
  Lists                ← .nav-sub-header
    - Destructuring with Cons

Design choices, matching the approach originally proposed on the issue:

  • / was chosen as the separator to match Hugo/Docusaurus conventions.
  • Fully backwards compatible: a category with no / renders identically to today (verified by a dedicated regression test).
  • One nesting level (parent/sub) is supported; deeper nesting isn't handled.
  • Parent ordering uses the lowest categoryindex of any document under it, including documents in its sub-categories, so a parent doesn't need its own separate front-matter entry.
  • Documents that share a parent but have no sub-category are listed directly under the parent header, before any sub-headers.
  • When the site uses a custom _menu_template.html (no built-in sub-header support in the templating system), sub-categories are flattened into their parent's single group so existing templates keep working unmodified.

Implementation

  • src/fsdocs-tool/DocContent.fs: getNavigationEntriesFactory now parses category into (parent, subCategory option), groups/sorts at both levels, and renders .nav-sub-header list items in the non-templated (default theme) path.
  • docs/content/fsdocs-default.css: added .nav-sub-header styling (indented, smaller, same color family as .nav-header, with an active state).
  • docs/content.fsx: documented the new category: Parent/Sub syntax.
  • RELEASE_NOTES.md: added an Unreleased / Added entry.

Test Status

  • ✅ dotnet fantomas src tests docs --check — clean, no formatting issues.
  • ✅ dotnet build FSharp.Formatting.sln -c Release — 0 errors, 0 warnings.
  • ✅ dotnet test tests/fsdocs-tool.Tests — 33/33 passed (added 2 new tests: one exercising the nested-category rendering end-to-end, one confirming a flat category renders unchanged).
  • ✅ dotnet test tests/FSharp.Literate.Tests --filter FullyQualifiedName~DocContent — 37/37 passed.
  • ✅ dotnet test tests/FSharp.Literate.Tests (full suite) — 146/146 passed.

Background

This reimplements the fix from #1105 (closed by @dsyme due to unrelated merge conflicts against a large Suave migration, not because the feature itself was rejected) against the current DocContent.fs/getNavigationEntriesFactory structure, since the file has since been substantially refactored.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4bc8419fad05e6b032741cbfd189986700bcf71c

…matter

Support 'category: Parent/Sub' syntax in document front matter. Documents
using a slash separator are grouped under a parent nav header, with a
sub-header rendered for each distinct sub-category beneath it. Documents
without a sub-category remain listed directly under the parent. Existing
flat categories are unchanged (no '/' -> identical output). Parent ordering
uses the minimum categoryindex of any document under it, including those
in its sub-categories.

Closes #927.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
dsyme marked this pull request as ready for review September 27, 2026 16:14
@nojaf

nojaf commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

/repo-assist

Thanks for picking this up. I'm going to close this PR. The sidebar code is neat, but it only covers the rendering, and that is the easy part. The parts I flagged as hard in #927 (next/previous links, menu templates, several levels) are either missing or worked around.

Previous/next links can disagree with the sidebar. The previous/next order still comes from sorting all pages by (categoryindex, index), and category names play no part in it. The sidebar now uses its own order: pages without a sub-category come first, and each sub-group is placed by the lowest categoryindex in it. Two examples:

  • Collections/Arrays and Collections/Lists share categoryindex: 1, which the docs in this PR suggest ("the parent's position is determined by the lowest categoryindex of any document under it"). The sidebar shows two groups, but next/previous mixes the Arrays and Lists pages by index. If two pages also share an index, the lookup finds the wrong page, and the second page gets the first page's links.
  • A plain Collections page with categoryindex: 3 is listed first in the sidebar. Next/previous puts it after a Collections/Lists page with categoryindex: 2.

It is not backwards compatible. Any existing category that contains a / changes meaning without warning: CI/CD becomes parent "CI" with sub-category "CD". You can't escape the /, and no message tells the user what happened.

Custom menu templates get nothing. With a _menu_template.html, the sub-categories are flattened into the parent group, and there is no new template parameter for a sub-header. Sites with their own template can't use the feature, and the sub-category names are lost.

Only one level. A/B/C gives parent A and sub-category B/C. The (parent, sub option) shape would have to be replaced by a real tree to go deeper, so this doesn't grow into multi-level support.

The tests don't check much. shouldContainText "Lists" also passes because of the page title. The "one parent header" claim is never checked, and every test page uses the same categoryindex and index, so ordering isn't really tested.

The original requester has moved on and the issue has no 👍 yet, so I don't want to commit to a front-matter syntax now. I'll keep #927 open to see if other people want this. If they do, I would start differently:

  • Use a separate front-matter key (or an explicit tree) instead of overloading category, so existing category names keep working.
  • Build the sidebar and the next/previous links from one ordered list of pages.
  • Decide the menu template parameters before writing any rendering code.

@nojaf nojaf closed this Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nesting Document Categories

2 participants