1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-21 17:34:25 +04:00

Fix: Exclude headings inside .example from the Table of Contents (#2354)

This commit is contained in:
BG-Software
2025-05-11 12:25:51 +02:00
committed by GitHub
parent 1867e0e482
commit 7773ff22b9
2 changed files with 7 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@tabler/docs": patch
---
Exclude headings inside `.example` from the Table of Contents

View File

@@ -1,4 +1,3 @@
import { appFilters } from "../shared/e11ty/filters.mjs" import { appFilters } from "../shared/e11ty/filters.mjs"
import { appData, getCopyList } from "../shared/e11ty/data.mjs"; import { appData, getCopyList } from "../shared/e11ty/data.mjs";
import { readFileSync, existsSync } from 'node:fs'; import { readFileSync, existsSync } from 'node:fs';
@@ -227,7 +226,8 @@ export default function (eleventyConfig) {
eleventyConfig.addFilter("toc", function (name) { eleventyConfig.addFilter("toc", function (name) {
const toc = []; const toc = [];
const headings = name.match(/<h([2-3])>([^<]+)<\/h\1>/g); const contentWithoutExamples = name.replace(/<div[^>]*\bclass=["'][^"']*\bexample\b[^"']*".*?>.*?<\/div>/gs, '');
const headings = contentWithoutExamples.match(/<h([23])>([^<]+)<\/h\1>/g);
if (headings) { if (headings) {
headings.forEach(heading => { headings.forEach(heading => {