diff --git a/apps/zitare/apps/web/src/lib/i18n/locales/de.json b/apps/zitare/apps/web/src/lib/i18n/locales/de.json index 2f6849c5b..9b38667dd 100644 --- a/apps/zitare/apps/web/src/lib/i18n/locales/de.json +++ b/apps/zitare/apps/web/src/lib/i18n/locales/de.json @@ -38,7 +38,12 @@ "courage": "Mut", "hope": "Hoffnung", "nature": "Natur", - "quotes": "{count} Zitate" + "quotes": "{count} Zitate", + "notFound": "Kategorie nicht gefunden", + "backToCategories": "Zurück zu Kategorien", + "searchInCategory": "In dieser Kategorie suchen...", + "sortByAuthor": "Nach Autor", + "sortByDefault": "Standard" }, "favorites": { "title": "Favoriten", diff --git a/apps/zitare/apps/web/src/lib/i18n/locales/en.json b/apps/zitare/apps/web/src/lib/i18n/locales/en.json index ee9b9fd53..67def3582 100644 --- a/apps/zitare/apps/web/src/lib/i18n/locales/en.json +++ b/apps/zitare/apps/web/src/lib/i18n/locales/en.json @@ -38,7 +38,12 @@ "courage": "Courage", "hope": "Hope", "nature": "Nature", - "quotes": "{count} quotes" + "quotes": "{count} quotes", + "notFound": "Category not found", + "backToCategories": "Back to categories", + "searchInCategory": "Search in this category...", + "sortByAuthor": "By author", + "sortByDefault": "Default" }, "favorites": { "title": "Favorites", diff --git a/apps/zitare/apps/web/src/routes/(app)/category/[category]/+page.svelte b/apps/zitare/apps/web/src/routes/(app)/category/[category]/+page.svelte index a8d4789d4..1b2da9342 100644 --- a/apps/zitare/apps/web/src/routes/(app)/category/[category]/+page.svelte +++ b/apps/zitare/apps/web/src/routes/(app)/category/[category]/+page.svelte @@ -2,7 +2,9 @@ import { page } from '$app/stores'; import { goto } from '$app/navigation'; import { _ } from 'svelte-i18n'; - import { getQuotesByCategory, CATEGORIES, type Category } from '@zitare/content'; + import { getQuotesByCategory, CATEGORIES, type Category, type Quote } from '@zitare/content'; + import { quotesStore } from '$lib/stores/quotes.svelte'; + import { zitareSettings } from '$lib/stores/settings.svelte'; import QuoteCard from '$lib/components/QuoteCard.svelte'; // Get category from URL @@ -14,6 +16,31 @@ // Get quotes for this category let quotes = $derived(isValidCategory ? getQuotesByCategory(category) : []); + // Search & sort state + let searchTerm = $state(''); + let sortBy = $state<'default' | 'author'>('default'); + + // Filtered and sorted quotes + let displayedQuotes = $derived(() => { + let filtered = quotes; + + // Filter by search + if (searchTerm.length >= 2) { + const lower = searchTerm.toLowerCase(); + filtered = filtered.filter( + (q) => + quotesStore.getText(q).toLowerCase().includes(lower) || + q.author.toLowerCase().includes(lower) + ); + } + + // Sort + if (sortBy === 'author') { + return [...filtered].sort((a, b) => a.author.localeCompare(b.author)); + } + return filtered; + }); + // Category labels const categoryLabels: Record = { weisheit: 'categories.wisdom', @@ -30,7 +57,9 @@ - Zitare - {isValidCategory ? $_(categoryLabels[category]) : 'Kategorie'} + Zitare - {isValidCategory ? $_(categoryLabels[category]) : $_('categories.notFound')}
@@ -47,20 +76,58 @@ {#if isValidCategory}

{$_(categoryLabels[category])}

-

+

{$_('categories.quotes', { values: { count: quotes.length } })}

-
- {#each quotes as quote (quote.id)} - - {/each} + +
+
+ + + + +
+
+ + {#if displayedQuotes.length === 0 && searchTerm.length >= 2} +
+

{$_('search.noResults')}

+
+ {:else} +
+ {#each displayedQuotes as quote (quote.id)} + + {/each} +
+ {/if} {:else}
-

Kategorie nicht gefunden

+

{$_('categories.notFound')}

{/if}