fix(landing): No hydration issues and fix i18n SSR warning

This commit is contained in:
2026-01-16 17:09:42 +01:00
parent 9cfa5ec434
commit 75f12ce775
22 changed files with 40 additions and 39 deletions

View File

@@ -18,9 +18,9 @@
}"
>
<template #title>
<NuxtLink to="/" class="flex items-center gap-2 sm:gap-3 group">
<div class="flex items-center gap-2 sm:gap-3">
<div
class="w-10 h-10 rounded-xl bg-linear-to-br from-primary-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-primary-500/25 group-hover:shadow-primary-500/40 transition-shadow"
class="w-10 h-10 rounded-xl bg-linear-to-br from-primary-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-primary-500/25"
>
<UIcon name="i-lucide-scale" class="w-5 h-5 text-white" />
</div>
@@ -29,7 +29,7 @@
>
GremiumHub
</span>
</NuxtLink>
</div>
</template>
<UNavigationMenu
@@ -183,7 +183,7 @@
<script setup lang="ts">
import type { NavigationMenuItem, DropdownMenuItem } from '@nuxt/ui'
const { t, locale, locales, setLocale } = useI18n()
const { t, locale, locales, setLocale } = useI18n({ useScope: 'global' })
// Locale dropdown menu items
const localeMenuItems = computed<DropdownMenuItem[]>(() =>
@@ -198,7 +198,8 @@ const localeMenuItems = computed<DropdownMenuItem[]>(() =>
)
// Track scroll position for header styling
const isScrolled = ref(false)
// Use useState to ensure consistent SSR/client hydration
const isScrolled = useState('header-scrolled', () => false)
onMounted(() => {
const handleScroll = () => {
@@ -206,7 +207,10 @@ onMounted(() => {
}
window.addEventListener('scroll', handleScroll, { passive: true })
handleScroll() // Check initial position
// Defer initial scroll check to avoid hydration mismatch
nextTick(() => {
handleScroll()
})
onUnmounted(() => {
window.removeEventListener('scroll', handleScroll)