Skip to content

Commit 8526b80

Browse files
committed
Remove Footnote entry from table of contents when footnotes present
1 parent 77dcae2 commit 8526b80

5 files changed

Lines changed: 78 additions & 565 deletions

File tree

‎_TODO.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ Need a tooltip component for consistency. List to add tooltips to:
103103
- Bug reporter modal
104104
- Email templates
105105

106+
## HubSpot Signup Issues
107+
108+
- Add people who sign up for newsletter, download, or fill out contact form to Hubspot tracking. Need to configure it to remove them if they do the GDPR remove me. Also remove them from the newsletter.
109+
110+
- If a reader has already given their email address - newsletter signup, contact form, download registration, then the download CTA on short form articles should go directly to the HTML version of the deep dive, and it should have a PDF download button. Think this workflow through - maybe a "Short / Deep-Dive" slider button on top and don't show the CTA + the PDF download button.
111+
106112
## Theming and improving Mermaid diagrams
107113

108114
[rerender diagrams when I switched color-scheme](https://github.com/mermaid-js/mermaid/issues/1945)
@@ -122,18 +128,12 @@ https://mermaid.js.org/config/directives.html
122128

123129
- Re-enable link validator in `astro.config.ts` when pdf / downloads sorted out
124130

125-
- Add people who sign up for newsletter, download, or fill out contact form to Hubspot tracking. Need to configure it to remove them if they do the GDPR remove me. Also remove them from the newsletter.
126-
127131
- Uppy, Tus server, whatever other server needed for file upload on Contact Form component
128132

129133
- Use an in-project Image component to wrap Astro's Image and Picture. Show a magnifying glass with a "+" for the cursor on hover, and a modal to show a magnified view of images on click.
130134

131135
- Add a copyright notice to content
132136

133-
- We need to exclude "Footnotes" from the ToC list of links. Right now it shows at the bottom if there's a Footnotes H2 (footnotes in the article).
134-
135-
- If a reader has already given their email address - newsletter signup, contact form, download registration, then the download CTA on short form articles should go directly to the HTML version of the deep dive, and it should have a PDF download button. Think this workflow through - maybe a "Short / Deep-Dive" slider button on top and don't show the CTA + the PDF download button.
136-
137137
- The articles list page should show tags at top for quick navigation. Show the count of articles per tag unless they're all the same on the tag.
138138

139139
- Update EXIF data on all AI generated JPGs

‎src/components/Toc/server/__fixtures__/headings.fixture.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
{ "slug": "section-one-details", "depth": 4, "text": "Deep Details" },
66
{ "slug": "section-two", "depth": 2, "text": "Section Two" },
77
{ "slug": "section-two-overview", "depth": 3, "text": "Overview" },
8-
{ "slug": "empty-heading", "depth": 2, "text": "" }
8+
{ "slug": "empty-heading", "depth": 2, "text": "" },
9+
{ "slug": "footnotes", "depth": 2, "text": "Footnotes" }
910
]

‎src/components/Toc/server/__tests__/index.spec.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,28 @@ describe('buildTocTree', () => {
3232

3333
expect(tree).toEqual([])
3434
})
35+
36+
it('excludes Footnotes headings from the tree', () => {
37+
const headings: MarkdownHeading[] = [
38+
{ slug: 'intro', depth: 2, text: 'Introduction' },
39+
{ slug: 'footnotes', depth: 2, text: 'Footnotes' },
40+
]
41+
42+
const tree = buildTocTree(headings)
43+
44+
expect(tree).toHaveLength(1)
45+
expect(tree[0]?.slug).toBe('intro')
46+
})
47+
48+
it('excludes Footnotes headings case-insensitively', () => {
49+
const headings: MarkdownHeading[] = [
50+
{ slug: 'intro', depth: 2, text: 'Introduction' },
51+
{ slug: 'footnotes', depth: 2, text: ' FOOTNOTES ' },
52+
]
53+
54+
const tree = buildTocTree(headings)
55+
56+
expect(tree).toHaveLength(1)
57+
expect(tree[0]?.slug).toBe('intro')
58+
})
3559
})

‎src/components/Toc/server/index.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export interface TocItem {
77
children: TocItem[]
88
}
99

10+
/** Heading texts excluded from the table of contents (case-insensitive) */
11+
const EXCLUDED_HEADINGS = new Set(['footnotes'])
12+
1013
export const buildTocTree = (headings: MarkdownHeading[]): TocItem[] => {
1114
const tree: TocItem[] = []
1215
const stack: TocItem[] = []
@@ -16,6 +19,11 @@ export const buildTocTree = (headings: MarkdownHeading[]): TocItem[] => {
1619
return
1720
}
1821

22+
// Skip headings that should not appear in the ToC (e.g. "Footnotes")
23+
if (EXCLUDED_HEADINGS.has(heading.text.trim().toLowerCase())) {
24+
return
25+
}
26+
1927
const node: TocItem = {
2028
depth: heading.depth,
2129
slug: heading.slug,

0 commit comments

Comments
 (0)