fix(andreknie.de): close accessibility and performance review gaps

This commit is contained in:
2026-07-29 00:05:18 +02:00
parent 88bd952a60
commit c4b5aa40ab
19 changed files with 198 additions and 58 deletions
+15 -6
View File
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react'
import content from 'virtual:content'
import detailLoaders from 'virtual:content-detail-loaders'
const detailCache = new Map()
const detailModulePromise = import('virtual:content-details')
/**
* Get all content of a given type, sorted by date descending.
@@ -65,11 +65,20 @@ export function useContentItem(type, slug) {
let active = true
if (!metadata || detailCache.has(cacheKey)) return () => { active = false }
detailModulePromise.then(module => {
const detail = module.default[type]?.find(candidate => candidate.slug === slug) || null
if (detail) detailCache.set(cacheKey, detail)
if (active) setDetailState({ key: cacheKey, item: detail })
})
const loadDetail = detailLoaders[type]?.[slug]
const detailPromise = loadDetail
? loadDetail()
: Promise.reject(new Error(`No detail loader for ${cacheKey}`))
detailPromise
.then(module => {
const detail = module.default
detailCache.set(cacheKey, detail)
if (active) setDetailState({ key: cacheKey, item: detail })
})
.catch(() => {
if (active) setDetailState({ key: cacheKey, item: { ...metadata, detailError: true } })
})
return () => { active = false }
}, [cacheKey, metadata, slug, type])