Skip to content

Conversation

ahmetcelik05
Copy link
Contributor

@ahmetcelik05 ahmetcelik05 commented Sep 4, 2025

Description

Resolves #23643

Checklist

  • I fully tested it as developer
  • no need to document

How to test it?

This PR should be tested in conjunction with the corresponding vs-internal PR.

Replaces client-side TOC generation with a new ITocGeneratorService and TocGeneratorService using HtmlAgilityPack. Updates the project page to render the TOC from the server, removes bootstrap-toc dependencies, and adjusts related JS and CSS for the new TOC structure. Adds HtmlAgilityPack as a dependency.
Introduces a Heading record to replace tuple usage for TOC headings, improving code readability and maintainability. Updates related logic in TocGeneratorService to use the new Heading type and adds constants for heading levels.
Replaces the previous HTML-based table of contents (TOC) extraction using HtmlAgilityPack with a Markdig-based approach. Introduces custom Markdig extensions and renderers to extract headings directly from markdown, updates the TOC service and interface, and removes the HtmlAgilityPack dependency from the project.
Replaces HTML-based TOC generation with a model-based approach by extracting heading data from markdown and rendering the table of contents via a new partial view. Removes the custom Markdig extension and related classes, updates the service interface, and adapts the page model and views to use the new heading list.
Replaces the internal Heading record in TocGeneratorService with a new public TocHeading record class. Updates all references and method signatures to use TocHeading, improving code clarity and reusability.
<nav id="docs-sticky-index" class="navbar index-scroll">
@Html.Raw(Model.TocHtml)
<nav id="toc" class="navbar index-scroll">
<partial name="TableOfContents" model="Model" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<partial name="TableOfContents" model="Model" />
<partial name="TableOfContents" model="Model.TocHeadings" />

@@ -0,0 +1,73 @@
@model Volo.Docs.Pages.Documents.Project.IndexModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@model Volo.Docs.Pages.Documents.Project.IndexModel
@model List<Heading>

@@ -0,0 +1,73 @@
@model Volo.Docs.Pages.Documents.Project.IndexModel
@{
if (Model.TocHeadings == null ||Model.TocHeadings.Count == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Model.TocHeadings == null ||Model.TocHeadings.Count == 0)
if (Model == null || Model.Count == 0)

return;
}

var relevantHeadings = Model.TocHeadings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var relevantHeadings = Model.TocHeadings
var relevantHeadings = Model


if (relevantHeadings.Count == 0)
{
relevantHeadings = Model.TocHeadings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
relevantHeadings = Model.TocHeadings
relevantHeadings = Model

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this file

Updated the TableOfContents partial to accept a List<TocHeading> instead of the full IndexModel, simplifying its interface. Adjusted the Index.cshtml to pass Model.TocHeadings directly. Removed the unused TableOfContents.cshtml.cs code-behind file.
ahmetcelik05 and others added 3 commits September 16, 2025 09:54
Replaces flat TocHeading list with hierarchical TocItem structure for document table of contents. Updates rendering logic, service interface, and implementation to support nested headings and configurable levels.
Enhanced TocGeneratorService by refactoring heading parsing, optimizing inline text extraction, and improving handling of empty or invalid markdown. Added helper methods for pipeline creation, heading construction, and inline processing for better readability and maintainability.
Replaces the use of a fixed max TOC level with a level count parameter in TOC generation methods and logic. This change improves flexibility by allowing the number of heading levels included in the TOC to be specified, rather than a maximum heading level value.
@yagmurcelk yagmurcelk merged commit 1393156 into dev Sep 22, 2025
3 checks passed
@yagmurcelk yagmurcelk deleted the Issue-#23643 branch September 22, 2025 08:02
@yagmurcelk yagmurcelk restored the Issue-#23643 branch September 22, 2025 08:06
@salihozkara salihozkara deleted the Issue-#23643 branch September 22, 2025 08:18
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.

Document Module - Render Table Of Contents on server-side
3 participants