mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-23 09:23:50 +01:00
36 lines
842 B
Vue
36 lines
842 B
Vue
<template>
|
|
<NuxtLink
|
|
:to="realHref"
|
|
:href="undefined"
|
|
>
|
|
<slot></slot>
|
|
</NuxtLink>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { parseURL, cleanDoubleSlashes, withTrailingSlash } from 'ufo';
|
|
import { RouteLocationRaw } from '#vue-router';
|
|
|
|
const rawProps = defineProps<{
|
|
to?: RouteLocationRaw | string;
|
|
href?: RouteLocationRaw | string;
|
|
}>();
|
|
|
|
const realHref = computed(() => {
|
|
const rhf = rawProps.to ?? rawProps.href;
|
|
|
|
if (rhf && typeof rhf === 'string') {
|
|
const runtimeConfig = useRuntimeConfig();
|
|
const rootDomain = parseURL(runtimeConfig.public.baseUrl);
|
|
const url = parseURL(rhf);
|
|
|
|
if (!url.host || rootDomain.host === url.host) {
|
|
return withTrailingSlash(rhf, true);
|
|
}
|
|
|
|
return cleanDoubleSlashes(rhf);
|
|
}
|
|
});
|
|
|
|
</script>
|