Skip to content
/ canvas Public template

Commit c6b2da9

Browse files
authored
feat: Use Locale Prefix for Nuxt Studio (#110)
1 parent 271687b commit c6b2da9

File tree

12 files changed

+53
-85
lines changed

12 files changed

+53
-85
lines changed

app/assets/style/animation.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
.list-move,
2+
.list-enter-active,
3+
.list-leave-active {
4+
transition: all 0.5s ease;
5+
}
6+
7+
.list-enter-from,
8+
.list-leave-to {
9+
opacity: 0;
10+
transform: translateY(30px);
11+
}
12+
13+
.list-leave-active {
14+
position: absolute;
15+
}
16+
117
.fade-enter-active,
218
.fade-leave-active {
319
transition: opacity .2s;
@@ -47,4 +63,4 @@
4763

4864
[data-animation-controller="false"] [data-animate] {
4965
animation: none;
50-
}
66+
}

app/components/Logo.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defineProps({
1010
</script>
1111

1212
<template>
13-
<NuxtLink
13+
<NuxtLinkLocale
1414
to="/"
1515
class="flex shrink-0 items-center"
1616
aria-label="Go back to home page"
@@ -25,5 +25,5 @@ defineProps({
2525
>
2626
{{ appName }}
2727
</span>
28-
</NuxtLink>
28+
</NuxtLinkLocale>
2929
</template>

app/components/content/Writing.vue

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const toggleTag = (tag: string) => {
100100
:key="article.path"
101101
>
102102
<ArticleCard
103-
:title="article.title!"
103+
:title="article.title"
104104
:date="article.date"
105105
:image="article.image"
106106
:path="article.path"
@@ -120,21 +120,3 @@ const toggleTag = (tag: string) => {
120120
</div>
121121
</section>
122122
</template>
123-
124-
<style>
125-
.list-move,
126-
.list-enter-active,
127-
.list-leave-active {
128-
transition: all 0.5s ease;
129-
}
130-
131-
.list-enter-from,
132-
.list-leave-to {
133-
opacity: 0;
134-
transform: translateY(30px);
135-
}
136-
137-
.list-leave-active {
138-
position: absolute;
139-
}
140-
</style>

app/components/home/CTA.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { t } = useI18n()
1010
:shortcuts="['⌘', 'O']"
1111
>
1212
<SpotlightButton>
13-
<NuxtLink
13+
<NuxtLinkLocale
1414
class="font-mona relative flex items-center justify-center gap-2 bg-gradient-to-b from-white/25 to-white bg-clip-text text-lg font-medium text-transparent transition-all duration-200"
1515
to="/contact"
1616
>
@@ -19,7 +19,7 @@ const { t } = useI18n()
1919
name="heroicons-envelope"
2020
class="size-5 text-white/80"
2121
/>
22-
</NuxtLink>
22+
</NuxtLinkLocale>
2323
</SpotlightButton>
2424
</UTooltip>
2525
<MeetingButton />

app/components/home/Projects.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ const { data: projects } = await useAsyncData('projects', async () => {
3535
</span>
3636
</NuxtLink>
3737
</div>
38-
<div @click="useRouter().push('/works')">
38+
<NuxtLinkLocale to="/works">
3939
<span class="font-newsreader italic text-white-shadow cursor-pointer">
4040
{{ $t("global.see_more") }}
4141
</span>
42-
</div>
42+
</NuxtLinkLocale>
4343
</div>
4444
</template>

app/components/layout/NavItem.vue

Lines changed: 0 additions & 33 deletions
This file was deleted.

app/components/layout/Navbar.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script lang="ts" setup>
2-
import type { Navigation } from '~/utils/useNavigation'
3-
42
defineProps({
53
isText: {
64
type: Boolean,
@@ -9,6 +7,9 @@ defineProps({
97
})
108
119
const navigation = getNavigation('home') as Record<string, Navigation>
10+
11+
const route = useRoute()
12+
const localePath = useLocalePath()
1213
</script>
1314

1415
<template>
@@ -27,11 +28,11 @@ const navigation = getNavigation('home') as Record<string, Navigation>
2728
:key="item.name"
2829
:aria-label="item.name + ' navigation link'"
2930
:class="[
30-
item.to === $route.path
31+
localePath(item.to) === route.path
3132
? 'border border-white/5 bg-zinc-900/10 text-white/75 shadow-2xl shadow-white/50 backdrop-blur-3xl text-shadow-sm'
3233
: 'text-muted',
3334
]"
34-
:to="item.to"
35+
:to="localePath(item.to)"
3536
class="flex items-center rounded-full border border-transparent px-4 py-1 transition-all duration-300 ease-in-out hover:border-white/5 hover:bg-zinc-900/50 hover:backdrop-blur-3xl sm:px-6"
3637
>
3738
<UIcon

app/components/settings/LanguageToggle.vue

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
<script setup lang="ts">
2-
const { locale: current, setLocaleCookie } = useI18n()
3-
4-
const locales = [
5-
{ code: 'en', name: 'English' },
6-
{ code: 'fr', name: 'Français' },
7-
]
2+
const { locale: current, setLocaleCookie, locales } = useI18n()
83
94
const currentLocale = computed(() => {
10-
return locales.find(locale => locale.code === current.value)
5+
return locales.value.find(locale => locale.code === current.value)
116
})
127
138
watch(current, (newLocale) => {
149
setLocaleCookie(newLocale)
1510
})
11+
12+
const switchLocalePath = useSwitchLocalePath()
1613
</script>
1714

1815
<template>
1916
<div class="z-99 flex items-center gap-3 rounded-lg border border-white/10 bg-zinc-900/90 px-3 py-1 backdrop-blur-xl">
2017
<ClientOnly>
21-
<div
18+
<NuxtLink
2219
v-for="locale in locales"
23-
:key="locale"
20+
:key="locale.code"
2421
class="cursor-pointer select-none"
25-
@click="$i18n.locale = locale.code"
22+
:to="switchLocalePath(locale.code)"
2623
>
2724
<span
2825
class="font-semibold"
29-
:class="locale.code === currentLocale.code ? 'text-white' : 'text-neutral-500'"
26+
:class="locale.code === currentLocale?.code ? 'text-white' : 'text-neutral-500'"
3027
>
3128
{{ locale.code }}
3229
</span>
33-
</div>
30+
</NuxtLink>
3431
<template #fallback>
3532
<div class="h-2 w-5" />
3633
</template>

app/layouts/default.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<SettingsLanguageToggle class="fixed bottom-20 right-3 z-50 sm:bottom-4" />
3+
<SettingsLanguageToggle class="fixed right-1 z-50 top-1" />
44
<LayoutNavbar class="fixed bottom-0 z-50 flex sm:bottom-auto sm:top-0" />
55
<div class="sm:mt-[50px]">
66
<slot />

app/pages/articles/[...slug].vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ defineOgImage({
4242
:page
4343
:is-writing="route.path.includes('/articles/')"
4444
/>
45-
<NuxtLink
45+
<NuxtLinkLocale
4646
to="/writing"
4747
class="mx-auto my-8 flex cursor-pointer items-center gap-2 px-4 text-muted hover:text-primary transition-colors duration-200 sm:max-w-2xl md:max-w-3xl lg:max-w-4xl"
4848
>
@@ -53,7 +53,7 @@ defineOgImage({
5353
<span class="text-sm font-extralight">
5454
{{ $t("navigation.writing") }}
5555
</span>
56-
</NuxtLink>
56+
</NuxtLinkLocale>
5757
<article class="writing mx-auto px-4 sm:max-w-2xl md:max-w-3xl lg:max-w-4xl">
5858
<h1>
5959
{{ page?.title }}

0 commit comments

Comments
 (0)