Skip to content

fix: add usePathWithLocal composables #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions apps/web/app/components/FooterPageSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useI18n } from '#i18n'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { useWithBase } from '#imports'
import { usePathWithLocale } from '#imports'
//#region types
type LinkList = {
href: string
Expand All @@ -15,7 +15,7 @@ const { t } = useI18n()
const { path: localePath } = useLocaleCurrent()
const { color } = useColor()
const { fontSize } = useTypography()
const withBase = useWithBase()
const pathWithLocale = usePathWithLocale()
//#endregion

//#region private variables
Expand All @@ -39,19 +39,19 @@ const snsLinkList: LinkList[] = [
]
const internalLinkList: LinkList[] = [
{
href: withBase('/events'),
href: '/events',
text: 'related_events.title',
},
{
href: withBase('/privacy'),
href: '/privacy',
text: 'privacy.title',
},
{
href: withBase('/code-of-conduct'),
href: '/code-of-conduct',
text: 'code_of_conduct.title',
},
{
href: withBase('/tokusho'),
href: '/tokusho',
text: 'tokusho.title',
},
]
Expand Down Expand Up @@ -94,7 +94,7 @@ const vueFesLinkList: LinkList[] = [
<div class="footer-link">
<ul class="footer-list">
<li v-for="(link, index) in internalLinkList" :key="index">
<VFTextLink :href="`${localePath}${link.href}`" color="white">
<VFTextLink :href="pathWithLocale(`${link.href}`)" color="white">
{{ t(link.text) }}
</VFTextLink>
</li>
Expand Down
6 changes: 3 additions & 3 deletions apps/web/app/components/SponsorPageSection.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useI18n } from '#i18n'
import { useLocaleCurrent, useRuntimeConfig, useWithBase } from '#imports'
import { useLocaleCurrent, useRuntimeConfig, usePathWithLocale } from '#imports'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { useTranslation } from '@/composables/useTranslation'
import SponsorList from './sponsor/SponsorList.vue'
Expand All @@ -22,7 +22,7 @@ const { translate } = useTranslation()

const currentLocale = useLocaleCurrent().locale

const withBase = useWithBase()
const pathWithLocale = usePathWithLocale()

// const periodStart = {
// prefixYear: t('prefix_year'),
Expand Down Expand Up @@ -186,7 +186,7 @@ const personalSponsorInfo: PersonalSponsorInfo = {
<div class="sponsor-buttons">
<VFLinkButton
class="sponsor-button"
:href="withBase(`${currentLocale === 'ja' ? '/' : `/${currentLocale}/`}jobboard`)"
:href="pathWithLocale('/jobboard')"
background-color="vue-green/200"
color="white"
>
Expand Down
5 changes: 3 additions & 2 deletions apps/web/app/components/ticket/NamecardSection.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { endedApplyNormal, endedCreateNamecard, ticketUrl } from '~/utils/constants'
import { useWithBase } from '#imports'
import { useWithBase, usePathWithLocale } from '#imports'

const { locale: currentLocale } = useLocaleCurrent()
const basePath = useWithBase()
const pathWithLocale = usePathWithLocale()
</script>

<template>
Expand Down Expand Up @@ -35,7 +36,7 @@ const basePath = useWithBase()
<div class="buttons-wrapper">
<VFLinkButton
class="action-button"
:href="basePath(`${currentLocale === 'ja' ? '/' : `/${currentLocale}/`}namecard/`)"
:href="pathWithLocale('/namecard')"
background-color="vue-green/200"
color="white"
>
Expand Down
14 changes: 14 additions & 0 deletions apps/web/app/composables/usePathWithLocale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useRuntimeConfig } from '#app'
import { useLocaleCurrent } from '#imports'

export function usePathWithLocale() {
const baseUrl = useRuntimeConfig().app.baseURL
const currentLocale = useLocaleCurrent().locale

function pathWithLocale(path: string) {
const localePath = `${currentLocale.value === 'ja' ? path : `/${currentLocale.value}/${path}`}`
return (baseUrl + localePath).replace(/\/\//g, '/')
}

return pathWithLocale
}
6 changes: 3 additions & 3 deletions apps/web/app/error.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useHead, useWithBase } from '#imports'
import { useHead, usePathWithLocale } from '#imports'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { conferenceTitle } from '~/utils/constants'
import { generalOg, twitterOg } from '~/utils/og.constants'
Expand All @@ -13,7 +13,7 @@ const props = defineProps<ErrorProps>()

const { fontWeight, fontSize } = useTypography()
const { color } = useColor()
const withBase = useWithBase()
const pathWithLocale = usePathWithLocale()

useHead({
// eslint-disable-next-line no-unused-vars
Expand Down Expand Up @@ -50,7 +50,7 @@ useHead({
background-color="white"
color="vue-blue"
target=""
:href="withBase('/')"
:href="pathWithLocale('/')"
>
{{ $t('back_to_top') }}
</VFLinkButton>
Expand Down
8 changes: 3 additions & 5 deletions apps/web/app/pages/code-of-conduct.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { useHead, useWithBase } from '#imports'
import { useHead, usePathWithLocale } from '#imports'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { conferenceTitle, linkUrl, ogCoCDescription } from '~/utils/constants'
import { generalOg, twitterOg } from '~/utils/og.constants'

Expand All @@ -24,10 +23,9 @@ useHead({
],
})

const { path: localePath } = useLocaleCurrent()
const { fontWeight, fontSize } = useTypography()
const { color } = useColor()
const withBase = useWithBase()
const pathWithLocale = usePathWithLocale()
</script>

<template>
Expand Down Expand Up @@ -59,7 +57,7 @@ const withBase = useWithBase()
background-color="white"
color="vue-blue"
target=""
:href="withBase(`${localePath}/`)"
:href="pathWithLocale('/')"
>
{{ $t('back_to_top') }}
</VFLinkButton>
Expand Down
22 changes: 14 additions & 8 deletions apps/web/app/pages/events.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { useFetch, useHead } from '#imports'
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { useFetch, useHead, usePathWithLocale } from '#imports'
import type { RelatedEventInfo } from '@vuejs-jp/model'
import { conferenceTitle, linkUrl, ogRelatedEventDescription } from '~/utils/constants'
import { generalOg, twitterOg } from '~/utils/og.constants'
Expand All @@ -13,10 +12,15 @@ if (error.value) {
}
const { eventsInfo } = data.value as RelatedEvents

const { path: localePath } = useLocaleCurrent()
const pathWithLocale = usePathWithLocale()

const isClose = (startedAt: string) =>
new Date() > new Date(new Date(startedAt).getFullYear(), new Date(startedAt).getMonth(), new Date(startedAt).getDate())
new Date() >
new Date(
new Date(startedAt).getFullYear(),
new Date(startedAt).getMonth(),
new Date(startedAt).getDate(),
)

useHead({
titleTemplate: (titleChunk) => `関連イベント | ${conferenceTitle}`,
Expand Down Expand Up @@ -46,7 +50,9 @@ useHead({
:src="event.bannerUrl"
:alt="event.title"
:register-url="event.registerUrl"
:register-action-text="isClose(event.startedAt) ? $t('related_events.close') : $t('related_events.register')"
:register-action-text="
isClose(event.startedAt) ? $t('related_events.close') : $t('related_events.register')
"
:disabled="isClose(event.startedAt)"
>
<template #title>
Expand All @@ -64,7 +70,7 @@ useHead({
background-color="white"
color="vue-blue"
target=""
:href="`${localePath}/`"
:href="pathWithLocale('/')"
>
{{ $t('back_to_top') }}
</VFLinkButton>
Expand All @@ -89,7 +95,7 @@ useHead({
}

&:before {
content: "";
content: '';
position: absolute;
display: block;
bottom: 0;
Expand Down Expand Up @@ -117,7 +123,7 @@ useHead({

@media (--tablet) {
padding: 20px 0 60px;
max-width: 100%
max-width: 100%;
}

li {
Expand Down
11 changes: 5 additions & 6 deletions apps/web/app/pages/jobboard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { useFetch, useHead } from '#imports'
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { useFetch, useHead, usePathWithLocale } from '#imports'
import type { JobInfo } from '@vuejs-jp/model'
import { conferenceTitle, linkUrl, ogJobboardDescription } from '~/utils/constants'
import { generalOg, twitterOg } from '~/utils/og.constants'
Expand All @@ -13,7 +12,7 @@ if (error.value) {
}
const { allJobs } = data.value as Jobs

const { path: localePath } = useLocaleCurrent()
const pathWithLocale = usePathWithLocale()

useHead({
titleTemplate: (titleChunk) => `ジョブボード | ${conferenceTitle}`,
Expand Down Expand Up @@ -50,7 +49,7 @@ useHead({
background-color="white"
color="vue-blue"
target=""
:href="`${localePath}/`"
:href="pathWithLocale('/')"
>
{{ $t('back_to_top') }}
</VFLinkButton>
Expand All @@ -75,7 +74,7 @@ useHead({
}

&:before {
content: "";
content: '';
position: absolute;
display: block;
bottom: 0;
Expand Down Expand Up @@ -103,7 +102,7 @@ useHead({

@media (--tablet) {
padding: 20px 0 60px;
max-width: 100%
max-width: 100%;
}

li {
Expand Down
10 changes: 4 additions & 6 deletions apps/web/app/pages/privacy.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<script setup lang="ts">
import { useHead, useI18n } from '#imports'
import { useHead, useI18n, usePathWithLocale } from '#imports'
import MarkDownText from '~/components/MarkDownText.vue'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { useLocaleCurrent } from '~/composables/useLocaleCurrent'
import { useColor } from '@vuejs-jp/composable'
import { conferenceTitle, linkUrl, ogPrivacyDescription } from '~/utils/constants'
import { generalOg, twitterOg } from '~/utils/og.constants'

const { t } = useI18n()
const { path: localePath } = useLocaleCurrent()
const { fontWeight, fontSize } = useTypography()
const pathWithLocale = usePathWithLocale()
const { color } = useColor()

useHead({
Expand Down Expand Up @@ -51,7 +49,7 @@ useHead({
background-color="white"
color="vue-blue"
target=""
:href="`${localePath}/`"
:href="pathWithLocale('/')"
>
{{ t('back_to_top') }}
</VFLinkButton>
Expand Down
Loading