Skip to content

Add HeadingSummary plugin for extracting article headings as navigation metadata#8

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/extract-blog-article-headings
Draft

Add HeadingSummary plugin for extracting article headings as navigation metadata#8
Copilot wants to merge 3 commits intomainfrom
copilot/extract-blog-article-headings

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 14, 2026

Implements a new HeadingSummary plugin that parses post HTML and stores a structured list of headings as document metadata, enabling in-page navigation (table of contents, sidebars, etc.).

New plugin: HeadingSummary

  • Heading.cs — Data model with Level (int), Id (string?), Text (string?)
  • HeadingSummaryModule.csParallelModule using HtmlAgilityPack to select h1h6 nodes and emit a List<Heading> under the "Headings" metadata key
  • HeadingSummaryConfigurator.csIConfigurator<Bootstrapper> that inserts the module into the Content pipeline at position 3, matching the ReadingTime pattern

Sample updates

  • 1.md — headings promoted to proper markdown with {#anchor-id} syntax
  • _sidebar.cshtml — renders Headings as a navigation <ul> with anchor links
  • Program.cs — explicitly registers both ReadingTimeConfigurator and HeadingSummaryConfigurator via AddConfigurator<Bootstrapper, T>()

Usage

Add headings with IDs in your markdown:

## My Section {#my-section}

Register the configurator in your Program.cs:

return await Bootstrapper
  .Factory
  .CreateWeb(args)
  .AddConfigurator<Bootstrapper, HeadingSummaryConfigurator>()
  .RunAsync();

Render in a template:

@{
    var headings = Model.GetList<Statiq.Plugins.Heading>("Headings");
}
@foreach (var heading in headings)
{
    <li class="heading-level-@heading.Level">
        <a href="#@heading.Id">@heading.Text</a>
    </li>
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Heading Summary</issue_title>
<issue_description>Extracting blog article headings for navigation from @ Jeremy Davis

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract blog article headings for navigation Add HeadingSummary plugin for extracting article headings as navigation metadata Mar 14, 2026
Copilot AI requested a review from AlexHedley March 14, 2026 09:34
@AlexHedley
Copy link
Copy Markdown
Owner

@copilot update the site project in the sample folder to use the plugin and confirm the it is working

Copy link
Copy Markdown
Author

Copilot AI commented Apr 17, 2026

@copilot update the site project in the sample folder to use the plugin and confirm the it is working

Done in c7c0c49. Updated sample/Program.cs to explicitly register both configurators using AddConfigurator<Bootstrapper, T>():

return await Bootstrapper
  .Factory
  .CreateWeb(args)
  .AddConfigurator<Bootstrapper, ReadingTimeConfigurator>()
  .AddConfigurator<Bootstrapper, HeadingSummaryConfigurator>()
  .RunAsync();

The site generates successfully (dotnet run) — the sample post's headings are rendered with the correct id attributes in the output HTML (e.g. <h2 id="what-is-lorem-ipsum">, <h2 id="why-do-we-use-it">, etc.), confirming the plugin extracts headings correctly from the documents.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Heading Summary

2 participants