- index and category pages paginate with ?page=N and 404 out of range - category content renders above the list through the html gate - related posts fall back to the latest posts - --journal-* tokens and neutral base styles - pl/en strings registered only for locales the app enables
40 lines
1.7 KiB
Vue
40 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
// Date, reading time, categories and author of a post. Links go through
|
|
// route names, so a disabled view renders its label as plain text.
|
|
import type { JournalPost } from '../../utils/types.ts'
|
|
import { formatJournalDate } from '../../utils/view.ts'
|
|
|
|
const props = defineProps<{ post: JournalPost }>()
|
|
const { localeProperties } = useI18n()
|
|
const links = useJournalLinks()
|
|
|
|
const date = computed(() => formatJournalDate(props.post.published_at, localeProperties.value.language ?? 'en'))
|
|
const authorName = computed(() => {
|
|
const a = props.post.author
|
|
return a ? `${a.first_name} ${a.last_name}`.trim() || a.login : ''
|
|
})
|
|
const authorHref = computed(() => (props.post.author ? links.authorLink(props.post.author.login) : null))
|
|
</script>
|
|
|
|
<template>
|
|
<div class="journal-post-meta">
|
|
<time v-if="date" class="journal-post-meta__date" :datetime="post.published_at ?? undefined">
|
|
{{ $t('journal.post.publishedOn', { date }) }}
|
|
</time>
|
|
<span v-if="post.reading_time > 0" class="journal-post-meta__reading">
|
|
{{ $t('journal.post.readingTime', { minutes: post.reading_time }) }}
|
|
</span>
|
|
<span v-if="authorName" class="journal-post-meta__author">
|
|
{{ $t('journal.post.by') }}
|
|
<NuxtLink v-if="authorHref" :to="authorHref">{{ authorName }}</NuxtLink>
|
|
<template v-else>{{ authorName }}</template>
|
|
</span>
|
|
<ul v-if="post.categories.length" class="journal-post-meta__categories">
|
|
<li v-for="cat in post.categories" :key="cat.id">
|
|
<NuxtLink v-if="links.categoryLink(cat.slug)" :to="links.categoryLink(cat.slug)!">{{ cat.name }}</NuxtLink>
|
|
<span v-else>{{ cat.name }}</span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</template>
|