oxynote/web/app/composables/useCurrentUrl.ts
2026-08-03 18:40:10 +02:00

20 lines
406 B
TypeScript

export default function () {
const config = useRuntimeConfig()
const route = useRoute()
function createCurrentUrl(options?: { hash?: string | null }) {
const url = new URL(route.fullPath || "/", config.public.appBaseURL)
if (options && "hash" in options) {
url.hash = options.hash || ""
}
return url
}
return {
currentUrl: computed(() => createCurrentUrl()),
createCurrentUrl,
}
}