This commit is contained in:
Daniel Ledda
2024-11-01 15:42:09 +01:00
parent f60e975765
commit 7539e6ed48
50 changed files with 2004 additions and 750 deletions

19
app/useHead.ts Normal file
View File

@@ -0,0 +1,19 @@
import { watchEffect, toValue, type MaybeRefOrGetter } from 'vue';
import useDJSSRContext from "@/useDJSSRContext.ts";
export default function useHead(params: {
title: MaybeRefOrGetter<string>,
}) {
const context = useDJSSRContext();
if (context) {
context.head.title = params.title;
} else {
watchEffect(() => {
const newTitle = toValue(params.title);
if (newTitle) {
document.title = newTitle;
}
});
}
}