--- import Base from '../../layouts/Base.astro'; import { fetchAllFragments, blobUrl, DID } from '../../lib/atproto'; import { renderMarkdownWithHeadings } from '../../lib/markdown'; import type { Fragment } from '../../lib/types'; export async function getStaticPaths() { const fragments = await fetchAllFragments(); return fragments.map(f => ({ params: { id: String(f.id) }, props: { fragment: f, allFragments: fragments }, })); } const { fragment, allFragments } = Astro.props as { fragment: Fragment; allFragments: Fragment[]; }; const { html, headings } = fragment.content ? await renderMarkdownWithHeadings(fragment.content) : { html: '', headings: [] }; const imageCount = fragment.images?.length ?? 0; const wordCount = fragment.content ? fragment.content.replace(/[#*_\[\]()>`~\-]/g, '').split(/\s+/).filter(Boolean).length : 0; // Prev/next by fragment ID const sorted = [...allFragments].sort((a, b) => a.id - b.id); const idx = sorted.findIndex(f => f.id === fragment.id); const prev = idx > 0 ? sorted[idx - 1] : null; const next = idx < sorted.length - 1 ? sorted[idx + 1] : null; // Related: same type, exclude current, newest first, take 6 const related = allFragments .filter(f => f.type === fragment.type && f.id !== fragment.id) .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()) .slice(0, 6); const typeAccent: Record = { post: 'var(--accent)', shot: 'var(--accent-2)', list: 'var(--list-accent)', link: 'var(--link-accent)', }; const accent = typeAccent[fragment.type] || 'var(--accent)'; const date = new Date(fragment.createdAt).toISOString().slice(0, 10); ---
← index {fragment.type} #{String(fragment.id).padStart(2, '0')}

{fragment.title}

{/* Shot gallery */} {fragment.type === 'shot' && fragment.images && (
{related.length > 0 && ( )}