Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b4be7907f | ||
|
|
f00082a5e9 |
@@ -1,5 +1,5 @@
|
||||
'use client'
|
||||
import React, { useState } from 'react'
|
||||
import React from 'react'
|
||||
import { motion } from 'framer-motion'
|
||||
import type { Page, Media } from '../../payload-types'
|
||||
import Link from 'next/link'
|
||||
@@ -43,7 +43,6 @@ export const HeroBlock: React.FC<Props> = ({
|
||||
floatingStat,
|
||||
whatsappNumber,
|
||||
}) => {
|
||||
const [imageLoaded, setImageLoaded] = useState(false)
|
||||
const whatsappLink = whatsappNumber ? `https://wa.me/${whatsappNumber}` : '#'
|
||||
|
||||
const heroMedia = typeof image === 'object' && image !== null ? (image as Media) : null
|
||||
@@ -69,10 +68,7 @@ export const HeroBlock: React.FC<Props> = ({
|
||||
fill
|
||||
priority
|
||||
sizes="100vw"
|
||||
onLoad={() => setImageLoaded(true)}
|
||||
className={`object-cover object-center transition-all duration-1000 ${
|
||||
imageLoaded ? 'opacity-100 scale-100' : 'opacity-0 scale-105'
|
||||
}`}
|
||||
className="object-cover object-center"
|
||||
/>
|
||||
{/* Ciemny gradient pod spodem, by biały tekst był świetnie czytelny, a zdjęcie pozostało nasycone */}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent lg:bg-gradient-to-r lg:from-black/90 lg:via-black/40 lg:to-transparent" />
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { i18n } from './i18n.config'
|
||||
|
||||
function getLocale(request: NextRequest): string {
|
||||
const acceptLanguage = request.headers.get('accept-language')
|
||||
const defaultLocale = i18n.defaultLocale
|
||||
const supportedLocales = i18n.locales.map((l) => l.code)
|
||||
|
||||
if (!acceptLanguage) {
|
||||
return defaultLocale
|
||||
}
|
||||
|
||||
// Very basic parser for Accept-Language header
|
||||
// Example header: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
|
||||
const languages = acceptLanguage
|
||||
.split(',')
|
||||
.map((lang) => {
|
||||
const [code, qValue] = lang.split(';q=')
|
||||
const quality = qValue ? parseFloat(qValue) : 1.0
|
||||
return { code: code.trim().split('-')[0].toLowerCase(), quality } // Extract primary subtag (e.g., 'en-US' -> 'en')
|
||||
})
|
||||
.sort((a, b) => b.quality - a.quality)
|
||||
|
||||
// Find the first matching supported locale
|
||||
for (const { code } of languages) {
|
||||
if (supportedLocales.includes(code as any)) {
|
||||
return code
|
||||
}
|
||||
}
|
||||
|
||||
return defaultLocale
|
||||
}
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl
|
||||
const locales = i18n.locales.map((l) => l.code)
|
||||
|
||||
// Bypass paths that should not be localized
|
||||
const bypassPaths = [
|
||||
'/api',
|
||||
'/_next',
|
||||
'/admin',
|
||||
'/favicon.ico',
|
||||
'/robots.txt',
|
||||
'/sitemap.xml',
|
||||
'/site.webmanifest',
|
||||
'/icon', // standard icons
|
||||
]
|
||||
|
||||
if (bypassPaths.some((path) => pathname.startsWith(path))) {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
// Check if there is any supported locale in the pathname
|
||||
const pathnameHasLocale = locales.some(
|
||||
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
|
||||
)
|
||||
|
||||
if (pathnameHasLocale) {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
// Redirect if there is no locale
|
||||
const locale = getLocale(request)
|
||||
request.nextUrl.pathname = `/${locale}${pathname}`
|
||||
|
||||
return NextResponse.redirect(request.nextUrl)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
// Matcher ignoring `/_next/` and `/api/`
|
||||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
|
||||
}
|
||||
Reference in New Issue
Block a user