Files
blog/frontend/app/composables/useLangSwitch.ts
T

17 lines
616 B
TypeScript
Raw Normal View History

/**
* Shared per-navigation state for the language-switch button in the layout.
* Each page sets this on setup: `available` is false when there is no
* equivalent page in the other language for the current content (e.g. an
* untranslated article, or the Italian-only corralito page) — in that case
* `fallback` is where the switch should go instead (typically the other
* language's blog index).
*/
interface LangSwitchState {
available: boolean
fallback: string
}
export function useLangSwitchState() {
return useState<LangSwitchState>('lang-switch', () => ({ available: true, fallback: '/en' }))
}