Skip to content

Commit e40db96

Browse files
committed
fix: add usePathWithLocal composables
1 parent 3b4c888 commit e40db96

File tree

7 files changed

+35
-24
lines changed

7 files changed

+35
-24
lines changed

apps/web/app/components/FooterPageSection.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useI18n } from '#i18n'
33
import { useColor, useTypography } from '@vuejs-jp/composable'
44
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
5-
import { useWithBase } from '#imports'
5+
import { usePathWithLocale } from '#imports'
66
//#region types
77
type LinkList = {
88
href: string
@@ -15,7 +15,7 @@ const { t } = useI18n()
1515
const { path: localePath } = useLocaleCurrent()
1616
const { color } = useColor()
1717
const { fontSize } = useTypography()
18-
const withBase = useWithBase()
18+
const pathWithLocale = usePathWithLocale()
1919
//#endregion
2020
2121
//#region private variables
@@ -39,19 +39,19 @@ const snsLinkList: LinkList[] = [
3939
]
4040
const internalLinkList: LinkList[] = [
4141
{
42-
href: withBase('/events'),
42+
href: pathWithLocale('/events'),
4343
text: 'related_events.title',
4444
},
4545
{
46-
href: withBase('/privacy'),
46+
href: pathWithLocale('/privacy'),
4747
text: 'privacy.title',
4848
},
4949
{
50-
href: withBase('/code-of-conduct'),
50+
href: pathWithLocale('/code-of-conduct'),
5151
text: 'code_of_conduct.title',
5252
},
5353
{
54-
href: withBase('/tokusho'),
54+
href: pathWithLocale('/tokusho'),
5555
text: 'tokusho.title',
5656
},
5757
]

apps/web/app/components/SponsorPageSection.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { useI18n } from '#i18n'
3-
import { useLocaleCurrent, useRuntimeConfig, useWithBase } from '#imports'
3+
import { useLocaleCurrent, useRuntimeConfig, usePathWithLocale } from '#imports'
44
import { useColor, useTypography } from '@vuejs-jp/composable'
55
import { useTranslation } from '@/composables/useTranslation'
66
import SponsorList from './sponsor/SponsorList.vue'
@@ -22,7 +22,7 @@ const { translate } = useTranslation()
2222
2323
const currentLocale = useLocaleCurrent().locale
2424
25-
const withBase = useWithBase()
25+
const pathWithLocale = usePathWithLocale()
2626
2727
// const periodStart = {
2828
// prefixYear: t('prefix_year'),
@@ -186,7 +186,7 @@ const personalSponsorInfo: PersonalSponsorInfo = {
186186
<div class="sponsor-buttons">
187187
<VFLinkButton
188188
class="sponsor-button"
189-
:href="withBase(`${currentLocale === 'ja' ? '/' : `/${currentLocale}/`}jobboard`)"
189+
:href="pathWithLocale('/jobboard')"
190190
background-color="vue-green/200"
191191
color="white"
192192
>

apps/web/app/components/ticket/NamecardSection.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script setup lang="ts">
22
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
33
import { endedApplyNormal, endedCreateNamecard, ticketUrl } from '~/utils/constants'
4-
import { useWithBase } from '#imports'
4+
import { useWithBase, usePathWithLocale } from '#imports'
55
66
const { locale: currentLocale } = useLocaleCurrent()
77
const basePath = useWithBase()
8+
const pathWithLocale = usePathWithLocale()
89
</script>
910

1011
<template>
@@ -35,7 +36,7 @@ const basePath = useWithBase()
3536
<div class="buttons-wrapper">
3637
<VFLinkButton
3738
class="action-button"
38-
:href="basePath(`${currentLocale === 'ja' ? '/' : `/${currentLocale}/`}namecard/`)"
39+
:href="pathWithLocale('/namecard')"
3940
background-color="vue-green/200"
4041
color="white"
4142
>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useRuntimeConfig } from '#app'
2+
import { useLocaleCurrent } from '#imports'
3+
4+
export function usePathWithLocale() {
5+
const baseUrl = useRuntimeConfig().app.baseURL
6+
const currentLocale = useLocaleCurrent().locale
7+
8+
function pathWithLocale(path: string) {
9+
const localePath = `${currentLocale.value === 'ja' ? path : `/${currentLocale.value}/${path}`}`
10+
return (baseUrl + localePath).replace(/\/\//g, '/')
11+
}
12+
13+
return pathWithLocale
14+
}

apps/web/app/error.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { useHead, useWithBase } from '#imports'
2+
import { useHead, usePathWithLocale } from '#imports'
33
import { useColor, useTypography } from '@vuejs-jp/composable'
44
import { conferenceTitle } from '~/utils/constants'
55
import { generalOg, twitterOg } from '~/utils/og.constants'
@@ -13,7 +13,7 @@ const props = defineProps<ErrorProps>()
1313
1414
const { fontWeight, fontSize } = useTypography()
1515
const { color } = useColor()
16-
const withBase = useWithBase()
16+
const pathWithLocale = usePathWithLocale()
1717
1818
useHead({
1919
// eslint-disable-next-line no-unused-vars
@@ -50,7 +50,7 @@ useHead({
5050
background-color="white"
5151
color="vue-blue"
5252
target=""
53-
:href="withBase('/')"
53+
:href="pathWithLocale('/')"
5454
>
5555
{{ $t('back_to_top') }}
5656
</VFLinkButton>

apps/web/app/pages/code-of-conduct.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
2-
import { useHead, useWithBase } from '#imports'
2+
import { useHead, usePathWithLocale } from '#imports'
33
import { useColor, useTypography } from '@vuejs-jp/composable'
4-
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
54
import { conferenceTitle, linkUrl, ogCoCDescription } from '~/utils/constants'
65
import { generalOg, twitterOg } from '~/utils/og.constants'
76
@@ -24,10 +23,9 @@ useHead({
2423
],
2524
})
2625
27-
const { path: localePath } = useLocaleCurrent()
2826
const { fontWeight, fontSize } = useTypography()
2927
const { color } = useColor()
30-
const withBase = useWithBase()
28+
const pathWithLocale = usePathWithLocale()
3129
</script>
3230

3331
<template>
@@ -59,7 +57,7 @@ const withBase = useWithBase()
5957
background-color="white"
6058
color="vue-blue"
6159
target=""
62-
:href="withBase(`${localePath}/`)"
60+
:href="pathWithLocale('/')"
6361
>
6462
{{ $t('back_to_top') }}
6563
</VFLinkButton>

apps/web/app/pages/tokusho.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
2-
import { useHead, useWithBase } from '#imports'
2+
import { useHead, usePathWithLocale } from '#imports'
33
import { useColor, useTypography } from '@vuejs-jp/composable'
4-
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
54
import { conferenceTitle, linkUrl, ogTokushoDescription } from '~/utils/constants'
65
import { generalOg, twitterOg } from '~/utils/og.constants'
76
@@ -24,10 +23,9 @@ useHead({
2423
],
2524
})
2625
27-
const { path: localePath } = useLocaleCurrent()
2826
const { fontWeight, fontSize } = useTypography()
2927
const { color } = useColor()
30-
const withBase = useWithBase()
28+
const pathWithLocale = usePathWithLocale()
3129
</script>
3230

3331
<template>
@@ -59,7 +57,7 @@ const withBase = useWithBase()
5957
background-color="white"
6058
color="vue-blue"
6159
target=""
62-
:href="withBase(`${localePath}/`)"
60+
:href="pathWithLocale('/')"
6361
>
6462
{{ $t('back_to_top') }}
6563
</VFLinkButton>

0 commit comments

Comments
 (0)