chore: transfer repo

This commit is contained in:
Danijel
2026-01-19 20:21:14 +01:00
commit 7d2fb0c737
213 changed files with 18085 additions and 0 deletions

40
middleware.ts Normal file
View File

@@ -0,0 +1,40 @@
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
// Middleware samo prosljeđuje zahtjeve
export function middleware(request: NextRequest) {
// Get the pathname
const { pathname } = request.nextUrl;
// Get the locale from cookie or default to 'hr'
const locale = request.cookies.get('NEXT_LOCALE')?.value || 'hr';
// Create a new URL based on the request
const newUrl = new URL(request.nextUrl);
// Check if we're on an English page
const isEnglishPage = pathname.startsWith('/en');
// Check if we're requesting the English version
const wantsEnglish = locale === 'en';
// If user wants English but we're not on an English page, redirect to English version
if (wantsEnglish && !isEnglishPage) {
newUrl.pathname = `/en${pathname}`;
return NextResponse.redirect(newUrl);
}
// If user wants Croatian but we're on an English page, redirect to Croatian version
if (!wantsEnglish && isEnglishPage) {
newUrl.pathname = pathname.replace(/^\/en/, '') || '/';
return NextResponse.redirect(newUrl);
}
return NextResponse.next();
}
// Za svaki slučaj, definiraj matcher
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico|assets).*)',
],
};