Skip to content

Commit 4dbc3c7

Browse files
committed
fix(nx-dev): toc should only include headings from the article body
1 parent 178e6ef commit 4dbc3c7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nx-dev/ui-blog/src/lib/blog-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function BlogDetails({ post, allPosts }: BlogDetailsProps) {
100100
</div>
101101

102102
{/* Main grid layout */}
103-
<div className="mx-auto max-w-7xl px-4 lg:px-8">
103+
<div className="mx-auto max-w-7xl px-4 lg:px-8" data-content-area>
104104
<div className="relative isolate grid grid-cols-1 gap-8 xl:grid-cols-[200px_minmax(0,1fr)_200px]">
105105
<div className="hidden min-h-full xl:block">
106106
{post.metrics && (

nx-dev/ui-markdoc/src/lib/tags/table-of-contents.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export function TableOfContents({
1818
const [headings, setHeadings] = useState<TocItem[]>([]);
1919

2020
useEffect(() => {
21-
// Find the main content wrapper where markdown content is rendered
22-
const content = document.querySelector('[data-document="main"]');
21+
// Find the content area where markdown content is rendered
22+
const content = document.querySelector('[data-content-area]');
2323
if (!content) return;
2424

2525
// Get all headings h1-h6 within the content
@@ -42,7 +42,7 @@ export function TableOfContents({
4242
}, [maxDepth]);
4343

4444
if (headings.length === 0) {
45-
return null;
45+
return <></>;
4646
}
4747

4848
return (

0 commit comments

Comments
 (0)