perf: review-fixes (N+1, waterfalls, sanitize-cache, lazy strommix)
- blog-utils.resolvePostOverviewBlocks: parallel getPostBySlug via Promise.all + .catch(null) instead of sequential await loop. - blog-utils.resolveCalendarBlocks: same fix for calendar items. - [...slug] page load: SearchableText/Calendar/DeadlineBanner now run parallel after tagsMap (was strict waterfall). - sanitize-blocks: LRU cache keyed on raw html input — sanitize-html is ~ms/KB, the same content repeats across pages and cache hits. - cms.getNormalizedTranslations: WeakMap-memoised the per-request Object.entries normalize loop on top of the existing 5-min bundle TTL. - cms.cached: opt-in dev cache via DEV_CACHE_CMS=1 (default still off). - rusty-image.ensureTransformedImage: was async-wrapping a sync URL builder; made sync, removed awaits at call sites — saves microtasks. - BlockRenderer: lazy-load StrommixBlock (~220 KB) via dynamic import in the template — pages without the live-strommix widget no longer ship its bundle. Also: enabled Caddy zstd+gzip on windwiderstand.de vhost (server-side edit; verified `content-encoding: zstd` on response). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-18
@@ -1,4 +1,4 @@
|
||||
import { getTranslationBundleBySlug } from '$lib/cms';
|
||||
import { getNormalizedTranslations } from '$lib/cms';
|
||||
import { isCmsAvailable } from '$lib/cms-health.server';
|
||||
import { maintenanceResponse } from '$lib/maintenance.server';
|
||||
import { TRANSLATION_BUNDLE_SLUG } from '$lib/constants';
|
||||
@@ -97,23 +97,10 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const bundle = await getTranslationBundleBySlug(TRANSLATION_BUNDLE_SLUG, { locale: 'de' });
|
||||
if (bundle?.strings && typeof bundle.strings === 'object') {
|
||||
const normalized: Record<string, string> = {};
|
||||
for (const [key, val] of Object.entries(bundle.strings)) {
|
||||
const v = val as unknown;
|
||||
const str =
|
||||
typeof v === 'string'
|
||||
? v
|
||||
: typeof v === 'object' && v !== null && 'value' in v
|
||||
? (v as { value?: unknown }).value
|
||||
: (v as { text?: unknown })?.text ?? (v as { label?: unknown })?.label;
|
||||
if (typeof str === 'string') normalized[key] = str;
|
||||
}
|
||||
event.locals.translations = normalized;
|
||||
} else {
|
||||
event.locals.translations = {};
|
||||
}
|
||||
event.locals.translations = await getNormalizedTranslations(
|
||||
TRANSLATION_BUNDLE_SLUG,
|
||||
{ locale: 'de' },
|
||||
);
|
||||
} catch (err) {
|
||||
event.locals.translations = {};
|
||||
logWarn('hooks.translations', err);
|
||||
|
||||
Reference in New Issue
Block a user