Skip to content

Commit 745a6ef

Browse files
committed
fix: add baseURL on GlobalHeader links
1 parent 8419912 commit 745a6ef

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

apps/web/app/components/GlobalHeader.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { useRuntimeConfig } from '#imports'
2+
import { useRuntimeConfig, useWithBase } from '#imports'
33
import { useI18n } from '#i18n'
44
import { useNav } from '~/composables/useNav'
55
import { useScreenOrientation, useWindowSize } from '@vueuse/core'
@@ -36,8 +36,10 @@ const toggleMenu = () => {
3636
showMenu.value = !showMenu.value
3737
}
3838
39+
const withBase = useWithBase()
3940
const getAnchorPath = computed(
40-
() => (anchor: string) => (locale.value === 'ja' ? `/${anchor}` : `/en/${anchor}`),
41+
() => (anchor: string) =>
42+
locale.value === 'ja' ? withBase(`/${anchor}`) : withBase(`en/${anchor}`),
4143
)
4244
</script>
4345

Lines changed: 11 additions & 0 deletions
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)