feat(blog): firma autore sotto il titolo, fallback Staff InsanityLab

This commit is contained in:
2026-07-05 22:15:30 +02:00
parent 2bf6b3d4de
commit 0f2b2ba014
+4 -1
View File
@@ -3,18 +3,21 @@ import Base from '../../layouts/Base.astro';
import Sidebar from '../../components/blog/Sidebar.astro'; import Sidebar from '../../components/blog/Sidebar.astro';
import { getDb } from '../../lib/db'; import { getDb } from '../../lib/db';
import { getPublishedBySlug } from '../../lib/posts'; import { getPublishedBySlug } from '../../lib/posts';
import { getUsernameById } from '../../lib/auth';
export const prerender = false; export const prerender = false;
const post = getPublishedBySlug(getDb(), Astro.params.slug!); const post = getPublishedBySlug(getDb(), Astro.params.slug!);
if (!post) return new Response(null, { status: 404 }); if (!post) return new Response(null, { status: 404 });
const fmt = new Intl.DateTimeFormat('it-IT', { dateStyle: 'long' }); const fmt = new Intl.DateTimeFormat('it-IT', { dateStyle: 'long' });
const author = post.author_id ? getUsernameById(getDb(), post.author_id) : null;
const byline = author ?? 'Staff InsanityLab';
--- ---
<Base title={post.title} description={post.excerpt}> <Base title={post.title} description={post.excerpt}>
<section class="section"> <section class="section">
<div class="container art"> <div class="container art">
<article> <article>
{post.cover && <img class="art__cover" src={post.cover} alt="" />} {post.cover && <img class="art__cover" src={post.cover} alt="" />}
<p class="art__meta">{post.published_at && fmt.format(new Date(post.published_at))} · {post.category}</p> <p class="art__meta">{post.published_at && fmt.format(new Date(post.published_at))} · {post.category} · di {byline}</p>
<h1>{post.title}</h1> <h1>{post.title}</h1>
<div class="art__body" set:html={post.body_html} /> <div class="art__body" set:html={post.body_html} />
</article> </article>