feat!: one link per post card and the heading convention

- JournalPostCard: the title link is the card's only anchor; the image is
  no longer a link and the separate read-more link is gone; the whole card
  stays clickable through a CSS stretched link with the focus ring on the
  card; prop headingLevel (2 | 3, default 2)
- related posts keep their h2 and render their cards at h3; JournalPostList
  passes headingLevel through
- smoke checks headings=strict (one h1, no skipped level) and cardlinks=N
  on every fixture page; expectation files for postTitleTag forced to h1
  and p (the documented two-h1 and no-h1 consequences)

BREAKING CHANGE: .journal-post-card__more and the image link
(.journal-post-card__image is now a div) are removed from post cards.
This commit is contained in:
Jakub Zych
2026-11-04 13:49:29 +01:00
parent 1010a603f0
commit 51e5d67576
9 changed files with 108 additions and 19 deletions

View File

@@ -1,26 +1,31 @@
<script setup lang="ts">
// One post in a listing: image, title link, date and excerpt.
// One post in a listing: image, title link, date and excerpt (UI-SPEC L5).
// The title link is the card's only anchor (D-80): the image is not a link
// and there is no separate "read more" link; the whole card is clickable
// through a CSS stretched link on the title (journal-base.css), with the
// focus ring on the card. Post links carry no rel. headingLevel is 2 in a
// listing and 3 under the related posts' own h2 (D-52).
import type { JournalPost } from '../../utils/types.ts'
import { formatJournalDate } from '../../utils/view.ts'
const props = defineProps<{ post: JournalPost }>()
const props = withDefaults(defineProps<{ post: JournalPost; headingLevel?: 2 | 3 }>(), { headingLevel: 2 })
const { localeProperties } = useI18n()
const links = useJournalLinks()
const href = computed(() => links.postLink(props.post.slug))
const date = computed(() => formatJournalDate(props.post.published_at, localeProperties.value.language ?? 'en'))
const heading = computed(() => (props.headingLevel === 3 ? 'h3' : 'h2'))
</script>
<template>
<article class="journal-post-card">
<NuxtLink v-if="href && post.featured_image_url" :to="href" class="journal-post-card__image" tabindex="-1" aria-hidden="true">
<div v-if="post.featured_image_url" class="journal-post-card__image">
<JournalFeaturedImage :src="post.featured_image_url" :alt="post.title" />
</NuxtLink>
<h2 class="journal-post-card__title">
</div>
<component :is="heading" class="journal-post-card__title">
<NuxtLink v-if="href" :to="href">{{ post.title }}</NuxtLink>
<template v-else>{{ post.title }}</template>
</h2>
</component>
<time v-if="date" class="journal-post-card__date" :datetime="post.published_at ?? undefined">{{ date }}</time>
<p v-if="post.excerpt" class="journal-post-card__excerpt">{{ post.excerpt }}</p>
<NuxtLink v-if="href" :to="href" class="journal-post-card__more">{{ $t('journal.readMore') }}</NuxtLink>
</article>
</template>

View File

@@ -1,13 +1,14 @@
<script setup lang="ts">
// A grid of post cards, or the empty-state text when there are none.
// headingLevel goes to every card (3 under the related posts' h2).
import type { JournalPost } from '../../utils/types.ts'
defineProps<{ posts: JournalPost[]; empty?: string }>()
defineProps<{ posts: JournalPost[]; empty?: string; headingLevel?: 2 | 3 }>()
</script>
<template>
<div class="journal-post-list">
<JournalPostCard v-for="post in posts" :key="post.id" :post="post" />
<JournalPostCard v-for="post in posts" :key="post.id" :post="post" :heading-level="headingLevel ?? 2" />
<p v-if="posts.length === 0" class="journal-post-list__empty">{{ empty ?? $t('journal.index.empty') }}</p>
</div>
</template>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
// Related posts under a post. The page passes the API's related_posts, or
// the latest posts when the post has no category.
// the latest posts when the post has no category. The section heading is an
// h2 and the cards' titles h3 (D-52).
import type { JournalPost } from '../../utils/types.ts'
defineProps<{ posts: JournalPost[] }>()
@@ -9,6 +10,6 @@ defineProps<{ posts: JournalPost[] }>()
<template>
<section v-if="posts.length" class="journal-related">
<h2 class="journal-related__title">{{ $t('journal.post.related') }}</h2>
<JournalPostList :posts="posts" />
<JournalPostList :posts="posts" :heading-level="3" />
</section>
</template>