Skip to content

Commit 115bc8c

Browse files
authoredApr 1, 2025
Merge pull request #386 from vuejs-jp/fix/add-baseurl
WIP: fix: add baseURL on TopPageSection links
2 parents 8419912 + 84c7d28 commit 115bc8c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎apps/web/app/components/TopPageSection.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<script setup lang="ts">
22
import { useI18n } from '#i18n'
33
import { computed } from 'vue'
4+
import { useWithBase } from '#imports'
45
56
const { locale } = useI18n()
67
8+
const withBase = useWithBase()
9+
710
const getAnchorPath = computed(
8-
() => (anchor: string) => (locale.value === 'ja' ? `/${anchor}` : `/en/${anchor}`),
11+
() => (anchor: string) =>
12+
locale.value === 'ja' ? withBase(`/${anchor}`) : withBase(`/en/${anchor}`),
913
)
1014
</script>
1115

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { useRuntimeConfig } from '#app'
2+
3+
export function useWithBase() {
4+
const baseUrl = useRuntimeConfig().app.baseURL
5+
6+
function withBase(path: string) {
7+
return (baseUrl + path).replace(/\/\//g, '/')
8+
}
9+
10+
return withBase
11+
}

0 commit comments

Comments
 (0)