From 8cbb1d2ef82a357c6a6a0c9dde9454680e3a5152 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Wed, 4 Sep 2024 22:11:01 +0200 Subject: [PATCH] Revert "Fix links in docs page when base path is set" This reverts commit d706d018f671b57dd14db7d2a64dfe125dc58a80. --- components/layouts/Docs.jsx | 20 ++++++-------------- components/search/SearchPanel.jsx | 11 +++-------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/components/layouts/Docs.jsx b/components/layouts/Docs.jsx index f7153dd54..61c8315f9 100644 --- a/components/layouts/Docs.jsx +++ b/components/layouts/Docs.jsx @@ -15,7 +15,6 @@ import { latestRelease, metadata as docsMetadata } from "../../docs/metadata/all import { filterLatestBugfixVersions } from "../../docs/metadata/helpers" import { Book, Code, Edit, List, Paperclip, X } from "react-feather" import styles from "./Docs.scss?type=global" -import Link from "next/link" const Docs = ({ metadata, allVersions, fallbackGitHubStars, toc, contents }) => { const tocRef = useRef() @@ -123,15 +122,10 @@ const Docs = ({ metadata, allVersions, fallbackGitHubStars, toc, contents }) => for (let il of internalLinks) { il.onclick = (e) => { e.preventDefault() - let href = Router.asPath - let hashpos = href.indexOf("#") - let hash = "" - if (hashpos >= 0) { - hash = href.substring(href.indexOf("#")) - href = href.substring(0, hashpos) - } + let href = window.location.href + let hash = href.substring(href.indexOf("#")) if (hash !== il.getAttribute("href")) { - Router.push(href + il.getAttribute("href")) + Router.push(window.location.pathname + il.getAttribute("href")) } else { onHashChangeStart(href) } @@ -211,11 +205,9 @@ const Docs = ({ metadata, allVersions, fallbackGitHubStars, toc, contents }) =>
{repository &&
{repository}
}
- - - API - - + + API +
{examples &&
{examples}
} {edit &&
{edit}
} diff --git a/components/search/SearchPanel.jsx b/components/search/SearchPanel.jsx index 86eaee580..5ba2fdeb0 100644 --- a/components/search/SearchPanel.jsx +++ b/components/search/SearchPanel.jsx @@ -8,15 +8,10 @@ import styles from "./SearchPanel.scss?type=global" const MAX_EXCERPT_LENGTH = 100 function pushRouter(id) { - let href = Router.asPath - let hashpos = href.indexOf("#") - let hash = "" - if (hashpos >= 0) { - hash = href.substring(href.indexOf("#") + 1) - href = href.substring(0, hashpos) - } + let href = window.location.href + let hash = href.substring(href.indexOf("#") + 1) if (hash !== id) { - Router.push(`${href}#${id}`) + Router.push(`${window.location.pathname}#${id}`) } }