c2e4576c42
Consolidate /rezepte and /recipes routes into single [recipeLang] structure to eliminate code duplication. All pages now use conditional API routing and reactive labels based on language parameter. - Merge duplicate route structures into /[recipeLang] with 404 for invalid slugs - Add English API endpoints for search, favorites, tags, and categories - Implement language dropdown in header with localStorage persistence - Convert all pages to use Svelte 5 runes (, , ) - Add German-only redirects (301) for add/edit pages - Make all view pages (list, detail, filters, search, favorites) fully bilingual - Remove floating language switcher in favor of header dropdown
25 lines
912 B
TypeScript
25 lines
912 B
TypeScript
import type { PageServerLoad } from "./$types";
|
|
import { redirect } from "@sveltejs/kit";
|
|
|
|
export const load: PageServerLoad = async ({ fetch, params, locals}) => {
|
|
// Edit is German-only - redirect to German version
|
|
if (params.recipeLang === 'recipes') {
|
|
// We need to get the German short_name first
|
|
const res = await fetch(`/api/recipes/items/${params.name}`);
|
|
if (res.ok) {
|
|
const recipe = await res.json();
|
|
throw redirect(301, `/rezepte/edit/${recipe.germanShortName}`);
|
|
}
|
|
// If recipe not found, redirect to German recipes list
|
|
throw redirect(301, '/rezepte');
|
|
}
|
|
|
|
let current_month = new Date().getMonth() + 1
|
|
const apiRes = await fetch(`/api/rezepte/items/${params.name}`);
|
|
const recipe = await apiRes.json();
|
|
const session = await locals.auth();
|
|
return {recipe: recipe,
|
|
user: session?.user
|
|
};
|
|
};
|