All files / apps/developer-portal/layers/docs/app/components/content ProseA.vue

100% Statements 5/5
100% Branches 8/8
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42    4x                                                 4x       4x       4x 4x          
<template>
    <NuxtLink
        v-if="file && repoUrl"
        :to="`${repoUrl}/blob/master/${file}`"
        target="_blank"
        external
    >
        <slot />
    </NuxtLink>
 
    <span v-else-if="file">
        <slot />
    </span>
 
    <NuxtLink v-else :href="props.href" :target="props.target">
        <slot />
    </NuxtLink>
</template>
 
<script setup lang="ts">
import { REPO_SCHEME } from "#layers/docs/shared/docLinks.ts";
 
interface Props {
    href?: string;
    target?: string;
}
 
const props = defineProps<Props>();
 
const {
    public: { repoUrl },
} = useRuntimeConfig();
 
// Everything else `remarkDocLinks` already resolved to a route; only the forge's own URL is runtime
// config, so only this half is left to the renderer.
const file = computed(() =>
    props.href?.startsWith(REPO_SCHEME)
        ? decodeURIComponent(props.href.slice(REPO_SCHEME.length))
        : null,
);
</script>