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,84 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getPageBySlug, getPages, getHomePageSlugFromConfig } from '$lib/cms';
|
||||
import { resolveContentImages, resolveImageUrls } from '$lib/rusty-image';
|
||||
import {
|
||||
resolvePostOverviewBlocks,
|
||||
resolveSearchableTextBlocks,
|
||||
resolveCalendarBlocks,
|
||||
} from '$lib/blog-utils';
|
||||
import { DEFAULT_HOME_PAGE_SLUG, PAGE_RESOLVE, SITE_NAME } from '$lib/constants';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
const translations = locals.translations ?? {};
|
||||
let homeSlug = DEFAULT_HOME_PAGE_SLUG;
|
||||
try {
|
||||
homeSlug = (await getHomePageSlugFromConfig({ locale: 'de' })) ?? DEFAULT_HOME_PAGE_SLUG;
|
||||
} catch {
|
||||
// fallback
|
||||
}
|
||||
|
||||
let page = null;
|
||||
let pages: Awaited<ReturnType<typeof getPages>> = [];
|
||||
|
||||
try {
|
||||
const [homePage, allPages] = await Promise.all([
|
||||
getPageBySlug(homeSlug, { locale: 'de', resolve: PAGE_RESOLVE }),
|
||||
getPages(),
|
||||
]);
|
||||
page = homePage;
|
||||
pages = allPages ?? [];
|
||||
if (page) {
|
||||
await resolveContentImages(page);
|
||||
const tagsMap = await resolvePostOverviewBlocks(page);
|
||||
await resolveSearchableTextBlocks(page, tagsMap);
|
||||
await resolveCalendarBlocks(page);
|
||||
}
|
||||
} catch {
|
||||
// CMS nicht erreichbar
|
||||
}
|
||||
|
||||
const siteName = (import.meta.env.PUBLIC_SITE_NAME as string | undefined) || SITE_NAME;
|
||||
|
||||
let topBanner: {
|
||||
banner: import('$lib/cms').FullwidthBannerEntry | null;
|
||||
resolvedImages: string[];
|
||||
headline?: string;
|
||||
subheadline?: string;
|
||||
} | null = null;
|
||||
if (page) {
|
||||
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]
|
||||
: [];
|
||||
let resolvedImages: string[] = [];
|
||||
if (bannerImages.length > 0) {
|
||||
resolvedImages = await resolveImageUrls(bannerImages as string[], {
|
||||
width: 2000,
|
||||
height: 750,
|
||||
fit: 'cover',
|
||||
format: 'webp',
|
||||
});
|
||||
}
|
||||
topBanner = {
|
||||
banner: bannerRaw as import('$lib/cms').FullwidthBannerEntry | null,
|
||||
resolvedImages,
|
||||
headline: page.headline ?? undefined,
|
||||
subheadline: page.subheadline ?? undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
page,
|
||||
pages,
|
||||
translations,
|
||||
topBanner,
|
||||
seoTitle: page
|
||||
? (page.seoTitle ?? page.headline ?? page.linkName ?? siteName)
|
||||
: siteName,
|
||||
seoDescription: page ? (page.seoDescription ?? page.subheadline ?? '') : '',
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user