docs: fix potential null errors (#2324)
This commit is contained in:
@@ -17,6 +17,8 @@ function setActiveLink(
|
|||||||
`a[href="#${id}"]`,
|
`a[href="#${id}"]`,
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
|
|
||||||
|
if (tocLink === null) return;
|
||||||
|
|
||||||
tocLink.classList.add("active");
|
tocLink.classList.add("active");
|
||||||
|
|
||||||
const rect = tocLink
|
const rect = tocLink
|
||||||
@@ -62,8 +64,10 @@ export function TableOfContents({ headings }: TableOfContentsProps) {
|
|||||||
const id = headings[i].id;
|
const id = headings[i].id;
|
||||||
const tocLink = container.querySelector(
|
const tocLink = container.querySelector(
|
||||||
`a[href="#${id}"]`,
|
`a[href="#${id}"]`,
|
||||||
) as HTMLElement;
|
);
|
||||||
tocLink.classList.remove("active");
|
if (tocLink !== null) {
|
||||||
|
tocLink.classList.remove("active");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let activeIdx = visibleList.indexOf(true);
|
let activeIdx = visibleList.indexOf(true);
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ export default function DocsPage(props: PageProps<Data>) {
|
|||||||
<div class="flex gap-6 md:gap-8 xl:gap-[8%] flex-col xl:flex-row md:mx-8 lg:mx-16 2xl:mx-0 lg:justify-end">
|
<div class="flex gap-6 md:gap-8 xl:gap-[8%] flex-col xl:flex-row md:mx-8 lg:mx-16 2xl:mx-0 lg:justify-end">
|
||||||
<TableOfContents headings={headings} />
|
<TableOfContents headings={headings} />
|
||||||
|
|
||||||
<div class="lg:order-1 min-w-0 max-w-3xl">
|
<div class="lg:order-1 min-w-0 max-w-3xl w-full">
|
||||||
<h1 class="text-4xl text-gray-900 tracking-tight font-bold md:mt-0 px-4 md:px-0 mb-4">
|
<h1 class="text-4xl text-gray-900 tracking-tight font-bold md:mt-0 px-4 md:px-0 mb-4">
|
||||||
{page.title}
|
{page.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user