All files / apps/developer-portal/layers/wiki/app/components WikiBroken.vue

100% Statements 10/10
100% Branches 1/1
100% Functions 7/7
100% Lines 10/10

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 43 44    6x             2x 2x           2x   2x                             6x 6x 5x 2x     3x        
<template>
    <UAlert
        v-if="broken.length > 0"
        color="warning"
        variant="subtle"
        icon="i-lucide-link-2-off"
        :title="$t('wikiBroken.title')"
    >
        <template #description>
            <div class="mt-1 flex flex-col gap-1">
                <NuxtLink
                    v-for="page in broken"
                    :key="page.path"
                    :to="page.to"
                    class="truncate font-mono text-xs hover:underline"
                >
                    {{ page.path }} → {{ page.links }}
                </NuxtLink>
            </div>
        </template>
    </UAlert>
</template>
 
<script setup lang="ts">
import { toCollectionPath } from "#layers/docs/shared/docPages.ts";
import type { DocPage } from "#layers/snapshot/shared/types/DocPage.ts";
 
interface Props {
    pages: DocPage[];
}
 
const { pages } = defineProps<Props>();
 
const broken = computed(() =>
    pages
        .filter((page) => page.brokenLinks.length > 0)
        .map((page) => ({
            path: page.path,
            to: `/wiki${toCollectionPath(page.path)}`,
            links: page.brokenLinks.map((link) => link.href).join(", "),
        })),
);
</script>