feat(post-page): separate headline and body content for improved rendering
- 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:
@@ -76,6 +76,14 @@ export const load: PageServerLoad = async ({ params, locals, url }) => {
|
||||
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 =
|
||||
((post as { row1Content?: unknown[] }).row1Content?.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,
|
||||
postDate,
|
||||
contentHtml,
|
||||
contentHeadlineHtml,
|
||||
contentBodyHtml,
|
||||
hasRowContent,
|
||||
isEvent,
|
||||
eventDateRaw,
|
||||
|
||||
Reference in New Issue
Block a user