🐛 Docs: 修复 wwads 造成的 client 水合不匹配 (#3106)

This commit is contained in:
StarHeart 2024-11-04 16:07:50 +08:00 committed by GitHub
parent d766455d13
commit 23bcab5450
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,19 +1,26 @@
import React from "react";
import "./styles.css";
import { useWindowSize } from "@nullbot/docusaurus-theme-nonepress/client";
import type { Props } from "@theme/Page/TOC/Container";
import OriginTOCContainer from "@theme-original/Page/TOC/Container";
import "./styles.css";
export default function TOCContainer({
children,
...props
}: Props): JSX.Element {
const windowSize = useWindowSize();
const isClient = windowSize !== "ssr";
return (
<OriginTOCContainer {...props}>
{children}
<div className="toc-ads-container">
<div className="wwads-cn wwads-vertical toc-ads" data-id="281"></div>
</div>
{isClient && (
<div className="toc-ads-container">
<div className="wwads-cn wwads-vertical toc-ads" data-id="281"></div>
</div>
)}
</OriginTOCContainer>
);
}