- post, index, category, tag and author pages render <SeoBreadcrumbs> at the top of their content while journal.breadcrumbs is on (default); false leaves the trail to the site's layout, the BreadcrumbList data is unchanged - JournalPagination renders <SeoPagination class-prefix="journal-pagination"> with the journal's labels: the same class names, plus page 1, the last page, gap items, aria labels and head rel prev/next, with links in the CMS's pagination form - with vue-seo-layer's seo.pagination.form 'path' the module registers <listing>/<segment>/:page routes (journalPagedRoutes), and the listing pages read the page from the :page param or ?page (pageFromRoute) - the category pillar text renders on page 1 only, the description on every page; an h1 in it becomes h2 while the category row's content_h1_to_h2 is on (absent counts as on)
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
// View shaping for SSR payloads. Pages run API rows through these in
|
|
// useAsyncData's transform, so the serialized payload carries only what the
|
|
// page renders: no raw `content` source and no `translations`. The post
|
|
// page's view, which sanitizes the body, is in postView.ts, so list pages and
|
|
// cards that import this file do not load the sanitizer.
|
|
|
|
import type { JournalPost } from './types.ts'
|
|
|
|
/** A post row as a list or card renders it: without body, source or translations. */
|
|
export function toListPost(post: JournalPost): JournalPost {
|
|
return { ...post, content: null, content_html: null, translations: null }
|
|
}
|
|
|
|
/**
|
|
* Formats an API timestamp as a long date for `language` (a BCP 47 tag such
|
|
* as "pl-PL"). UTC on both server and browser, so hydration matches. Returns
|
|
* "" for a missing or invalid value.
|
|
*/
|
|
export function formatJournalDate(iso: string | null | undefined, language: string): string {
|
|
if (!iso) return ''
|
|
const d = new Date(iso)
|
|
if (Number.isNaN(d.getTime())) return ''
|
|
try {
|
|
return new Intl.DateTimeFormat(language || 'en', { dateStyle: 'long', timeZone: 'UTC' }).format(d)
|
|
} catch {
|
|
return new Intl.DateTimeFormat('en', { dateStyle: 'long', timeZone: 'UTC' }).format(d)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* True while the journal pages render <SeoBreadcrumbs> at the top of their
|
|
* content (journal.breadcrumbs, NUXT_PUBLIC_JOURNAL_BREADCRUMBS; default on).
|
|
*/
|
|
export function journalBreadcrumbsOn(option: unknown): boolean {
|
|
return option !== false && option !== 'false'
|
|
}
|