feat(post-page): separate headline and body content for improved rendering
Deploy / verify (push) Successful in 45s
Deploy / deploy (push) Successful in 59s

- Extracted headline and body content from the post's HTML, allowing for distinct rendering of the headline and body in the post page.
- Updated the Svelte component to display the extracted headline and body content separately, enhancing the layout and readability of posts.
This commit is contained in:
Peter Meier
2026-04-19 21:56:30 +02:00
parent 2d0a6a7747
commit a18c0a8cf7
2 changed files with 26 additions and 12 deletions
+10
View File
@@ -76,6 +76,14 @@ export const load: PageServerLoad = async ({ params, locals, url }) => {
contentHtml = await processMarkdownHtmlImages(contentHtml); contentHtml = await processMarkdownHtmlImages(contentHtml);
} }
let contentHeadlineHtml = '';
let contentBodyHtml = contentHtml;
const h1Match = contentHtml.match(/^\s*(<h1\b[^>]*>[\s\S]*?<\/h1>)([\s\S]*)$/);
if (h1Match) {
contentHeadlineHtml = h1Match[1];
contentBodyHtml = h1Match[2];
}
const hasRowContent = const hasRowContent =
((post as { row1Content?: unknown[] }).row1Content?.length ?? 0) > 0 || ((post as { row1Content?: unknown[] }).row1Content?.length ?? 0) > 0 ||
((post as { row2Content?: unknown[] }).row2Content?.length ?? 0) > 0 || ((post as { row2Content?: unknown[] }).row2Content?.length ?? 0) > 0 ||
@@ -199,6 +207,8 @@ export const load: PageServerLoad = async ({ params, locals, url }) => {
postImageFocal: postImageField?.focal ?? null, postImageFocal: postImageField?.focal ?? null,
postDate, postDate,
contentHtml, contentHtml,
contentHeadlineHtml,
contentBodyHtml,
hasRowContent, hasRowContent,
isEvent, isEvent,
eventDateRaw, eventDateRaw,
+16 -12
View File
@@ -32,16 +32,6 @@
{/if} {/if}
</svelte:head> </svelte:head>
{#if data.isEvent && (data.eventDateLabel || data.eventLocationText)}
<div class="mb-6">
<EventBadges
eventDate={data.eventDateRaw}
locationText={data.eventLocationText}
locationHref={(data.mapEmbedUrl || data.mapLinkUrl) ? '#map-section' : null}
/>
</div>
{/if}
<div class="md:flex gap-2 items-end"> <div class="md:flex gap-2 items-end">
{#if data.rawPostImageUrl} {#if data.rawPostImageUrl}
<div class="overflow-hidden inline-block my-4 border border-white self-start ring-1 ring-black/50 shadow-lg"> <div class="overflow-hidden inline-block my-4 border border-white self-start ring-1 ring-black/50 shadow-lg">
@@ -83,9 +73,23 @@
</div> </div>
<article class="mt-8"> <article class="mt-8">
{#if data.contentHtml} {#if data.contentHeadlineHtml}
<div class="content markdown max-w-none prose prose-zinc"> <div class="content markdown max-w-none prose prose-zinc">
{@html data.contentHtml} {@html data.contentHeadlineHtml}
</div>
{/if}
{#if data.isEvent && (data.eventDateLabel || data.eventLocationText)}
<div class="mb-6">
<EventBadges
eventDate={data.eventDateRaw}
locationText={data.eventLocationText}
locationHref={(data.mapEmbedUrl || data.mapLinkUrl) ? '#map-section' : null}
/>
</div>
{/if}
{#if data.contentBodyHtml}
<div class="content markdown max-w-none prose prose-zinc">
{@html data.contentBodyHtml}
</div> </div>
{/if} {/if}
{#if data.hasRowContent} {#if data.hasRowContent}