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 | 3x 1x 16x 8x 8x 1x 1x 1x 1x 2x 1x 2x 2x 2x 18x | <template>
<div class="w-120 p-5">
<p v-if="status === 'pending' || subjects.length" :id="titleId" class="text-kicker">
{{ $t("navSubjectsPanel.title") }}
</p>
<template v-if="status === 'pending'">
<p class="sr-only">{{ $t("common.loading") }}</p>
<ul aria-hidden="true" class="mt-2 grid grid-cols-2 gap-x-6">
<li v-for="row in SUBJECTS" :key="row" class="flex min-h-10 items-center">
<USkeleton class="h-4 w-36" />
</li>
</ul>
</template>
<ul
v-else-if="subjects.length"
:aria-labelledby="titleId"
class="mt-2 grid grid-cols-2 gap-x-6"
>
<li v-for="{ value, count } in subjects" :key="value.id">
<ULink
raw
:to="{ name: 'category', params: { slug: value.slug } }"
class="flex min-h-10 items-baseline justify-between gap-3 py-2 font-serif text-base text-highlighted underline-title hover:underline focus-visible:rounded-xs"
>
<span class="truncate">{{ value.name }}</span>
<span class="font-sans text-meta text-muted tabular-nums">
<span aria-hidden="true">{{ count }}</span>
<span class="sr-only">{{
$t("navSubjectsPanel.count", { count }, count)
}}</span>
</span>
</ULink>
</li>
</ul>
<div class="not-first:mt-3 not-first:border-t not-first:border-default not-first:pt-2">
<ULink
raw
:to="{ name: 'categories' }"
class="inline-flex min-h-10 items-center gap-1.5 font-sans text-sm font-semibold text-primary underline-offset-4 hover:underline focus-visible:rounded-xs"
>
{{ $t("navSubjectsPanel.all") }}
<UIcon name="i-lucide-arrow-right" class="size-4" />
</ULink>
</div>
</div>
</template>
<script setup lang="ts">
const SUBJECTS = 8;
const titleId = useId();
const { data: home, status } = useCachedFetch<Home>("/api/home");
const subjects = computed<Facet<Category>[]>(
() => home.value?.subjects.toSorted((a, b) => b.count - a.count).slice(0, SUBJECTS) ?? [],
);
</script>
|