Files
timmal/app/composables/usePageTitle.ts

16 lines
451 B
TypeScript
Raw Permalink Normal View History

2025-12-07 21:27:23 +01:00
export const usePageTitle = () => {
2025-12-07 21:27:23 +01:00
const pageName = useState<string | null>('pageName', () => null);
const title = computed<string>(() => ((pageName.value ?? '').length > 0 ? `${pageName.value} - Tímmál` : 'Tímmál'));
2025-12-07 21:27:23 +01:00
2025-12-07 21:27:23 +01:00
const setPageName = (newName: string | null) => {
2025-12-07 21:27:23 +01:00
pageName.value = newName;
useHead({ title: title.value });
};
return {
title: readonly(title),
pageName: readonly(pageName),
setPageName,
};
};