Fixed content collections
This commit is contained in:
parent
c94fb25aba
commit
65d4339b9f
12 changed files with 67 additions and 111 deletions
src/utils
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue