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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 72x 16x 18x 38x 38x 38x 61x 56x 4x 72x 72x 72x 72x 56x 61x 72x | <template>
<div class="flex items-center gap-3 font-sans text-meta text-muted">
<UAvatarGroup v-if="avatars" size="lg" aria-hidden="true" :ui="{ base: '-me-2' }">
<UAvatar
v-for="author in authors"
:key="author.id"
:src="author.avatar?.url"
:text="initials(author.name)"
alt=""
/>
</UAvatarGroup>
<div class="overflow-hidden">
<ul
class="-ml-5 flex flex-wrap gap-y-1 [&>li]:flex [&>li]:before:w-5 [&>li]:before:shrink-0 [&>li]:before:text-center [&>li]:before:text-dimmed [&>li]:before:content-['ยท'/'']"
>
<li class="text-toned">
<!-- One inline box: as flex items, the separators would lose the spaces around "y" -->
<span>
<template v-for="({ literal, author }, key) in names" :key>
<template v-if="literal">{{ literal }}</template>
<ULink
v-else-if="author"
:to="author.to"
raw
class="font-semibold text-highlighted underline-offset-3 hover:underline focus-visible:rounded-xs"
>{{ author.name }}</ULink
>
</template>
</span>
</li>
<li v-if="date">
<time :datetime="publishedAt">{{ date }}</time>
</li>
<li v-if="readingMinutes">
{{
$t("articleByline.readingTime", { minutes: readingMinutes }, readingMinutes)
}}
</li>
<li v-if="comments?.count">
<ULink
:to="comments.to"
raw
class="underline-offset-3 hover:underline focus-visible:rounded-xs"
>
{{
$t("articleByline.comments", { count: comments.count }, comments.count)
}}
</ULink>
</li>
</ul>
</div>
</div>
</template>
<script setup lang="ts">
import type { RouteLocationRaw } from "vue-router";
type BylineAuthor = Pick<Author, "id" | "name" | "avatar"> & { to: RouteLocationRaw };
interface BylineComments {
count: number;
to: RouteLocationRaw;
}
interface Props {
authors: BylineAuthor[];
publishedAt?: string;
readingMinutes?: number;
comments?: BylineComments;
avatars?: boolean;
}
const props = withDefaults(defineProps<Props>(), { avatars: false });
const { locale, d } = useI18n();
const names = computed(() =>
new Intl.ListFormat(locale.value, { type: "conjunction" })
.formatToParts(props.authors.map((_, index) => String(index)))
.map(({ type, value }) =>
type === "element" ? { author: props.authors[+value] } : { literal: value },
),
);
const date = computed<string | undefined>(() => props.publishedAt && d(props.publishedAt, "long"));
</script>
|