add route matcher to fix /login and /logout routes
Some checks failed
CI / update (push) Failing after 2m52s
Some checks failed
CI / update (push) Failing after 2m52s
Use SvelteKit param matcher to constrain [recipeLang] to only match 'recipes' or 'rezepte', preventing it from catching /login, /logout, and other non-recipe routes.
This commit is contained in:
79
src/routes/[recipeLang=recipeLang]/favorites/+page.svelte
Normal file
79
src/routes/[recipeLang=recipeLang]/favorites/+page.svelte
Normal file
@@ -0,0 +1,79 @@
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
import '$lib/css/nordtheme.css';
|
||||
import Recipes from '$lib/components/Recipes.svelte';
|
||||
import Card from '$lib/components/Card.svelte';
|
||||
import Search from '$lib/components/Search.svelte';
|
||||
let { data }: { data: PageData } = $props();
|
||||
let current_month = new Date().getMonth() + 1;
|
||||
|
||||
const isEnglish = $derived(data.lang === 'en');
|
||||
const labels = $derived({
|
||||
title: isEnglish ? 'Favorites' : 'Favoriten',
|
||||
pageTitle: isEnglish ? 'My Favorites - Bocken Recipes' : 'Meine Favoriten - Bocken Rezepte',
|
||||
metaDescription: isEnglish
|
||||
? 'My favorite recipes from Bocken\'s kitchen.'
|
||||
: 'Meine favorisierten Rezepte aus der Bockenschen Küche.',
|
||||
count: isEnglish
|
||||
? `${data.favorites.length} favorite recipe${data.favorites.length !== 1 ? 's' : ''}`
|
||||
: `${data.favorites.length} favorisierte Rezepte`,
|
||||
noFavorites: isEnglish ? 'No favorites saved yet' : 'Noch keine Favoriten gespeichert',
|
||||
errorLoading: isEnglish ? 'Error loading favorites:' : 'Fehler beim Laden der Favoriten:',
|
||||
emptyState1: isEnglish
|
||||
? 'You haven\'t saved any recipes as favorites yet.'
|
||||
: 'Du hast noch keine Rezepte als Favoriten gespeichert.',
|
||||
emptyState2: isEnglish
|
||||
? 'Visit a recipe and click the heart icon to add it to your favorites.'
|
||||
: 'Besuche ein Rezept und klicke auf das Herz-Symbol, um es zu deinen Favoriten hinzuzufügen.',
|
||||
recipesLink: isEnglish ? 'recipe' : 'Rezept'
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
h1{
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
font-size: 4rem;
|
||||
}
|
||||
.subheading{
|
||||
text-align: center;
|
||||
margin-top: 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.empty-state{
|
||||
text-align: center;
|
||||
margin-top: 3rem;
|
||||
color: var(--nord3);
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>{labels.pageTitle}</title>
|
||||
<meta name="description" content={labels.metaDescription} />
|
||||
</svelte:head>
|
||||
|
||||
<h1>{labels.title}</h1>
|
||||
<p class=subheading>
|
||||
{#if data.favorites.length > 0}
|
||||
{labels.count}
|
||||
{:else}
|
||||
{labels.noFavorites}
|
||||
{/if}
|
||||
</p>
|
||||
|
||||
<Search favoritesOnly={true} lang={data.lang}></Search>
|
||||
|
||||
{#if data.error}
|
||||
<p class="empty-state">{labels.errorLoading} {data.error}</p>
|
||||
{:else if data.favorites.length > 0}
|
||||
<Recipes>
|
||||
{#each data.favorites as recipe}
|
||||
<Card {recipe} {current_month} isFavorite={true} showFavoriteIndicator={true} routePrefix="/{data.recipeLang}"></Card>
|
||||
{/each}
|
||||
</Recipes>
|
||||
{:else}
|
||||
<div class="empty-state">
|
||||
<p>{labels.emptyState1}</p>
|
||||
<p><a href="/{data.recipeLang}">{labels.emptyState2}</a></p>
|
||||
</div>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user