Skip to content

Commit

Permalink
Revert "Fix links in docs page when base path is set"
Browse files Browse the repository at this point in the history
This reverts commit d706d01.
  • Loading branch information
vietj committed Sep 4, 2024
1 parent ccc535c commit 8cbb1d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
20 changes: 6 additions & 14 deletions components/layouts/Docs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -211,11 +205,9 @@ const Docs = ({ metadata, allVersions, fallbackGitHubStars, toc, contents }) =>
<div className="docs-content-metadata-left">
{repository && <div className="docs-content-metadata-repo">{repository}</div>}
<div>
<Link href={`/docs/${currentVersion.version ? `${currentVersion.version}/` : ""}apidocs`}>
<a>
<Book className="feather" /> API
</a>
</Link>
<a href={`/docs/${currentVersion.version ? `${currentVersion.version}/` : ""}apidocs`}>
<Book className="feather" /> API
</a>
</div>
{examples && <div className="docs-content-metadata-examples">{examples}</div>}
{edit && <div className="docs-content-metadata-edit">{edit}</div>}
Expand Down
11 changes: 3 additions & 8 deletions components/search/SearchPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}

Expand Down

0 comments on commit 8cbb1d2

Please sign in to comment.