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

100% Statements 17/17
100% Branches 2/2
100% Functions 8/8
100% Lines 15/15

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68  6x 15x 2x 2x 22x           22x 2x 2x                             6x                                         6x   6x 18x         30x   22x         18x      
<template>
    <div class="flex flex-col gap-5">
        <section v-for="group in groups" :key="group.label" class="flex flex-col gap-2">
            <h2 class="text-sm font-semibold">{{ group.label }}</h2>
            <div class="grid gap-3 sm:grid-cols-2">
                <NuxtLink
                    v-for="entry in group.items"
                    :key="entry.to"
                    :to="entry.to"
                    class="flex flex-col gap-1 rounded-lg border border-default bg-default p-4 transition-colors hover:bg-elevated/50"
                >
                    <UIcon :name="entry.icon" class="size-4 text-primary" />
                    <span class="text-sm font-medium">{{ entry.label }}</span>
                    <span class="text-xs text-dimmed">{{ entry.hint }}</span>
                </NuxtLink>
            </div>
        </section>
    </div>
</template>
 
<script setup lang="ts">
interface Props {
    /** Every path in the wiki tree, so a link to a doc that is gone is left out. */
    known: Set<string>;
}
 
const { known } = defineProps<Props>();
 
const GROUPS = [
    {
        id: "explore",
        items: [
            { id: "overview", to: "/wiki/readme", icon: "i-lucide-map" },
            { id: "catalog", to: "/projects", icon: "i-lucide-boxes" },
        ],
    },
    {
        id: "understand",
        items: [
            { id: "boundaries", to: "/wiki/docs/concepts/boundaries", icon: "i-lucide-git-branch" },
            { id: "graph", to: "/graph", icon: "i-lucide-git-fork" },
        ],
    },
    {
        id: "contribute",
        items: [{ id: "firstHour", to: "/wiki/docs/guides/first-hour", icon: "i-lucide-play" }],
    },
];
 
const { t } = useI18n();
 
const groups = computed(() =>
    GROUPS.map((group) => ({
        label: t(`wikiStart.groups.${group.id}`),
        items: group.items
            .filter(
                (entry) =>
                    !entry.to.startsWith("/wiki/") || known.has(entry.to.slice("/wiki".length)),
            )
            .map((entry) => ({
                ...entry,
                label: t(`wikiStart.items.${entry.id}.label`),
                hint: t(`wikiStart.items.${entry.id}.hint`),
            })),
    })).filter((group) => group.items.length > 0),
);
</script>