faith: progressive enhancement for all faith pages without JS
All checks were successful
CI / update (push) Successful in 1m29s

- Rosary: mystery selection, luminous toggle, and latin toggle fall back
  to URL params (?mystery=, ?luminous=, ?latin=) for no-JS navigation
- Prayers/Angelus: latin toggle uses URL param fallback
- Search on prayers page hidden without JS (requires DOM queries)
- Toggle component supports href prop for link-based no-JS self-submit
- LanguageSelector uses <a> links with computed paths and :focus-within
  dropdown for no-JS; displays correct language via server-provided prop
- Recipe language links use translated slugs from $page.data
- URL params cleaned via replaceState after hydration to avoid clutter
This commit is contained in:
2026-02-04 14:14:11 +01:00
parent 1c100a4534
commit 7d6a80442a
13 changed files with 347 additions and 90 deletions

View File

@@ -6,9 +6,10 @@ const LANGUAGE_CONTEXT_KEY = Symbol('language');
/**
* Creates or updates a language context for prayer components
* @param {Object} options
* @param {'de' | 'en'} options.urlLang - The URL language (de for /glaube, en for /faith)
* @param {'de' | 'en'} [options.urlLang] - The URL language (de for /glaube, en for /faith)
* @param {boolean} [options.initialLatin] - Initial state for Latin/bilingual display
*/
export function createLanguageContext({ urlLang = 'de' } = {}) {
export function createLanguageContext({ urlLang = 'de', initialLatin = true } = {}) {
// Check if context already exists (e.g., during navigation)
if (hasContext(LANGUAGE_CONTEXT_KEY)) {
const existing = getContext(LANGUAGE_CONTEXT_KEY);
@@ -17,7 +18,7 @@ export function createLanguageContext({ urlLang = 'de' } = {}) {
return existing;
}
const showLatin = writable(true); // true = bilingual (Latin + vernacular), false = monolingual
const showLatin = writable(initialLatin); // true = bilingual (Latin + vernacular), false = monolingual
const lang = writable(urlLang); // 'de' or 'en' based on URL
setContext(LANGUAGE_CONTEXT_KEY, {