fix(nx-dev): toc should only include headings from the article body
This commit is contained in:
parent
178e6ef3c7
commit
4dbc3c7156
@ -100,7 +100,7 @@ export function BlogDetails({ post, allPosts }: BlogDetailsProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main grid layout */}
|
{/* Main grid layout */}
|
||||||
<div className="mx-auto max-w-7xl px-4 lg:px-8">
|
<div className="mx-auto max-w-7xl px-4 lg:px-8" data-content-area>
|
||||||
<div className="relative isolate grid grid-cols-1 gap-8 xl:grid-cols-[200px_minmax(0,1fr)_200px]">
|
<div className="relative isolate grid grid-cols-1 gap-8 xl:grid-cols-[200px_minmax(0,1fr)_200px]">
|
||||||
<div className="hidden min-h-full xl:block">
|
<div className="hidden min-h-full xl:block">
|
||||||
{post.metrics && (
|
{post.metrics && (
|
||||||
|
|||||||
@ -18,8 +18,8 @@ export function TableOfContents({
|
|||||||
const [headings, setHeadings] = useState<TocItem[]>([]);
|
const [headings, setHeadings] = useState<TocItem[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Find the main content wrapper where markdown content is rendered
|
// Find the content area where markdown content is rendered
|
||||||
const content = document.querySelector('[data-document="main"]');
|
const content = document.querySelector('[data-content-area]');
|
||||||
if (!content) return;
|
if (!content) return;
|
||||||
|
|
||||||
// Get all headings h1-h6 within the content
|
// Get all headings h1-h6 within the content
|
||||||
@ -42,7 +42,7 @@ export function TableOfContents({
|
|||||||
}, [maxDepth]);
|
}, [maxDepth]);
|
||||||
|
|
||||||
if (headings.length === 0) {
|
if (headings.length === 0) {
|
||||||
return null;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user