From 6febb283f6822b9c9db048e23ddc8205f696133a Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Thu, 16 May 2024 15:35:17 -0700 Subject: [PATCH] docs[minor]: Hide prev/next buttons on docs in how to / tutorials (#21789) These buttons don't navigate to the proper prev/next page. Hide in those pages --- docs/src/theme/DocPaginator/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 docs/src/theme/DocPaginator/index.js diff --git a/docs/src/theme/DocPaginator/index.js b/docs/src/theme/DocPaginator/index.js new file mode 100644 index 0000000000..f1b99c6582 --- /dev/null +++ b/docs/src/theme/DocPaginator/index.js @@ -0,0 +1,22 @@ +import React from "react"; +import DocPaginator from "@theme-original/DocPaginator"; + +const BLACKLISTED_PATHS = ["/docs/how_to/", "/docs/tutorials/"]; + +export default function DocPaginatorWrapper(props) { + const [shouldHide, setShouldHide] = React.useState(false); + + React.useEffect(() => { + if (typeof window === "undefined") return; + const currentPath = window.location.pathname; + if (BLACKLISTED_PATHS.some((path) => currentPath.includes(path))) { + setShouldHide(true); + } + }, []); + + if (!shouldHide) { + // eslint-disable-next-line react/jsx-props-no-spreading + return ; + } + return null; +}