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:
5
.changeset/strong-frogs-brush.md
Normal file
5
.changeset/strong-frogs-brush.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tabler/docs": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Exclude headings inside `.example` from the Table of Contents
|
||||||
@@ -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 => {
|
||||||
|
|||||||
Reference in New Issue
Block a user