Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b83485

Browse files
committed
refactor: algolia navigator
1 parenta138dbf commit7b83485

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

‎src/components/AlgoliaDocSearch.vue‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
a
12
<script setup lang="ts">
23
importdocsearchfrom'@docsearch/js'
34
@@ -15,7 +16,17 @@ function initialize() {
1516
const options=Object.assign({},userOptions, {
1617
navigator: {
1718
navigate({itemUrl }: { itemUrl:string }) {
18-
router.push(itemUrl)
19+
const {pathname: hitPathname }=newURL(
20+
window.location.origin+itemUrl
21+
)
22+
23+
// router doesn't handle same-page navigation so we use the native
24+
// browser location API for anchor navigation
25+
if (route.path===hitPathname) {
26+
window.location.assign(window.location.origin+itemUrl)
27+
}else {
28+
router.push(itemUrl)
29+
}
1930
},
2031
},
2132
@@ -75,6 +86,15 @@ const getRelativePath = (absoluteUrl: string) => {
7586
7687
returnpathname+hash
7788
}
89+
// function getRelativePath(absoluteUrl: string) {
90+
// const { pathname, hash } = new URL(absoluteUrl)
91+
// return (
92+
// pathname.replace(
93+
// /\.html$/,
94+
// site.value.cleanUrls === 'disabled' ? '.html' : ''
95+
// ) + hash
96+
// )
97+
// }
7898
7999
onMounted(()=> {
80100
initialize()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp