statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.64k stars 235 forks source link

Process multiple heading levels #904

Closed drmathias closed 4 years ago

drmathias commented 4 years ago

Hi, I was looking to generate a table of contents with multiple levels of headings. Was looking at retrieving the list of headings and then parsing the heading level for styling.

IReadOnlyList<IDocument> headings = Document.GetDocumentList(HtmlKeys.Headings);
foreach (IDocument heading in headings) {
    int level = heading.GetInt(HtmlKeys.Level);
    string text = await heading.GetContentStringAsync();
}

Currently from what I can gather, Statiq.Web is configured to currently only processes top level headings.

new GatherHeadings()

Could it instead be configured to process headings up to h6?

daveaglick commented 4 years ago

Great idea - and I think we can do one better. Instead of a global setting, I might be able to pull the level from document metadata so that you could specify a global level and/or a per-document level.

daveaglick commented 4 years ago

Nice to have an easy one for a change :). Keep an eye out for the next release.