Skip to content

Directives: add list-sub-pages directive#2847

Open
reakaleek wants to merge 1 commit intomainfrom
feature/list-sub-pages-directive
Open

Directives: add list-sub-pages directive#2847
reakaleek wants to merge 1 commit intomainfrom
feature/list-sub-pages-directive

Conversation

@reakaleek
Copy link
Member

What

  • Add a new {list-sub-pages} directive that renders a list of child pages for the current section
  • Each entry shows the page title as a link, with an optional description from frontmatter (separated by an em dash)

Why

  • Index pages often need a way to list their child pages so readers can discover content within a section
  • This directive automates that listing based on the TOC structure, removing the need to manually maintain link lists

Notes

  • The directive resolves pages from the navigation tree at parse time, so ResolveDirectoryTree must run before ParseFullAsync — the base DirectiveTest was updated to call it, which caused a pre-existing test (IncludeNeedsToLiveInSpecialFolder) to see an extra diagnostic; the assertion was relaxed to accommodate this
  • Descriptions come from IDocumentationFile.Description (frontmatter description field); a future improvement could use DescriptionGenerator as a fallback when no frontmatter description is set

Made with Cursor

Comment on lines +44 to +59
foreach (var item in parent.NavigationItems)
{
if (item.Hidden)
continue;
if (item.Url == currentUrl)
continue;

var description = item switch
{
ILeafNavigationItem<IDocumentationFile> leaf => leaf.Model.Description,
INodeNavigationItem<INavigationModel, INavigationItem> node when node.Index.Model is IDocumentationFile doc => doc.Description,
_ => null
};

subPages.Add(new SubPageEntry(item.NavigationTitle, item.Url, description));
}
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

🔍 Preview links for changed docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants