Initial SvelteKit frontend port of windwiderstand.de
Full parity with Astro site: content rows, post/tag routes, pagination, event badges + OSM map, comments, Live-Search via /api/search-index, CMS image proxy, RSS, sitemap. Deploy: Dockerfile + docker-compose.prod.yml + Gitea Actions workflow to build + push to git.pm86.de registry and ssh-deploy to Contabo.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getPageBySlug } from '$lib/cms';
|
||||
import { resolveContentImages, resolveImageUrls } from '$lib/rusty-image';
|
||||
import {
|
||||
resolvePostOverviewBlocks,
|
||||
resolveSearchableTextBlocks,
|
||||
resolveCalendarBlocks,
|
||||
} from '$lib/blog-utils';
|
||||
import { PAGE_RESOLVE } from '$lib/constants';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ params, locals }) => {
|
||||
const { slug } = params;
|
||||
const translations = locals.translations ?? {};
|
||||
|
||||
const page = await getPageBySlug(slug, {
|
||||
locale: 'de',
|
||||
resolve: PAGE_RESOLVE,
|
||||
});
|
||||
|
||||
if (!page) {
|
||||
error(404, 'Seite nicht gefunden');
|
||||
}
|
||||
|
||||
await resolveContentImages(page);
|
||||
const tagsMap = await resolvePostOverviewBlocks(page);
|
||||
await resolveSearchableTextBlocks(page, tagsMap);
|
||||
await resolveCalendarBlocks(page);
|
||||
|
||||
// Resolve top banner if present
|
||||
let topBannerResolvedImages: string[] = [];
|
||||
const bannerRaw = (page as { topFullwidthBanner?: unknown }).topFullwidthBanner;
|
||||
if (bannerRaw && typeof bannerRaw === 'object' && 'image' in bannerRaw) {
|
||||
const bannerImages = Array.isArray((bannerRaw as { image?: unknown }).image)
|
||||
? ((bannerRaw as { image?: unknown[] }).image ?? [])
|
||||
: (bannerRaw as { image?: unknown }).image != null
|
||||
? [(bannerRaw as { image?: unknown }).image]
|
||||
: [];
|
||||
if (bannerImages.length > 0) {
|
||||
topBannerResolvedImages = await resolveImageUrls(bannerImages as string[], {
|
||||
width: 2000,
|
||||
height: 750,
|
||||
fit: 'cover',
|
||||
format: 'webp',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
page,
|
||||
translations,
|
||||
seoTitle: page.seoTitle ?? page.headline ?? page.linkName ?? slug,
|
||||
seoDescription: page.seoDescription ?? page.subheadline ?? '',
|
||||
breadcrumbItems: [
|
||||
{ href: '/', label: 'Start' },
|
||||
{ label: page.headline ?? page.linkName ?? page.slug ?? page._slug ?? slug },
|
||||
],
|
||||
topBanner: bannerRaw
|
||||
? {
|
||||
banner: bannerRaw as import('$lib/cms').FullwidthBannerEntry | null,
|
||||
resolvedImages: topBannerResolvedImages,
|
||||
headline: page.headline ?? undefined,
|
||||
subheadline: page.subheadline ?? undefined,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user