Fixed content collections

This commit is contained in:
Firq-ow 2024-01-09 14:30:28 +01:00
parent c94fb25aba
commit 65d4339b9f
Signed by: Firq
GPG key ID: BC5CE35A72BDB4AB
12 changed files with 67 additions and 111 deletions
src/utils

View file

@ -1,9 +1,16 @@
export function findSlug(filepath: string) {
return filepath.match(/(?:.*[\\/])(.+)(?:\.json)/)?.[1]
import { getEntry } from 'astro:content'
export function plsLoadImage(
record: Record<string, () => Promise<{ default: ImageMetadata }>>,
path: string
) {
const loadedImage = record[path]?.()
if (!loadedImage) throw new Error('Asset was not found:' + path)
return loadedImage
}
export function plsLoadImage(record: Record<string, () => Promise<{default: ImageMetadata}>>, path: string) {
const loadedImage = record[path]?.();
if (!loadedImage) throw new Error("Asset was not found:" + path);
return loadedImage;
export async function plsLoadTAEntry(key: string) {
const filecontent = (await getEntry('taInfoData', key))?.data
if (!filecontent) throw new Error(`Datafile ${key} is missing!`)
return filecontent
}