blank project
This commit is contained in:
20
node_modules/astro/dist/content/loaders/errors.d.ts
generated
vendored
Normal file
20
node_modules/astro/dist/content/loaders/errors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { ZodError } from 'zod';
|
||||
export declare class LiveCollectionError extends Error {
|
||||
readonly collection: string;
|
||||
readonly message: string;
|
||||
readonly cause?: Error | undefined;
|
||||
constructor(collection: string, message: string, cause?: Error | undefined);
|
||||
static is(error: unknown): error is LiveCollectionError;
|
||||
}
|
||||
export declare class LiveEntryNotFoundError extends LiveCollectionError {
|
||||
constructor(collection: string, entryFilter: string | Record<string, unknown>);
|
||||
static is(error: unknown): error is LiveEntryNotFoundError;
|
||||
}
|
||||
export declare class LiveCollectionValidationError extends LiveCollectionError {
|
||||
constructor(collection: string, entryId: string, error: ZodError);
|
||||
static is(error: unknown): error is LiveCollectionValidationError;
|
||||
}
|
||||
export declare class LiveCollectionCacheHintError extends LiveCollectionError {
|
||||
constructor(collection: string, entryId: string | undefined, error: ZodError);
|
||||
static is(error: unknown): error is LiveCollectionCacheHintError;
|
||||
}
|
||||
67
node_modules/astro/dist/content/loaders/errors.js
generated
vendored
Normal file
67
node_modules/astro/dist/content/loaders/errors.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
class LiveCollectionError extends Error {
|
||||
constructor(collection, message, cause) {
|
||||
super(message);
|
||||
this.collection = collection;
|
||||
this.message = message;
|
||||
this.cause = cause;
|
||||
this.name = "LiveCollectionError";
|
||||
if (cause?.stack) {
|
||||
this.stack = cause.stack;
|
||||
}
|
||||
}
|
||||
static is(error) {
|
||||
return error instanceof LiveCollectionError;
|
||||
}
|
||||
}
|
||||
class LiveEntryNotFoundError extends LiveCollectionError {
|
||||
constructor(collection, entryFilter) {
|
||||
super(
|
||||
collection,
|
||||
`Entry ${collection} \u2192 ${typeof entryFilter === "string" ? entryFilter : JSON.stringify(entryFilter)} was not found.`
|
||||
);
|
||||
this.name = "LiveEntryNotFoundError";
|
||||
}
|
||||
static is(error) {
|
||||
return error?.name === "LiveEntryNotFoundError";
|
||||
}
|
||||
}
|
||||
class LiveCollectionValidationError extends LiveCollectionError {
|
||||
constructor(collection, entryId, error) {
|
||||
super(
|
||||
collection,
|
||||
[
|
||||
`**${collection} \u2192 ${entryId}** data does not match the collection schema.
|
||||
`,
|
||||
...error.errors.map((zodError) => ` **${zodError.path.join(".")}**: ${zodError.message}`),
|
||||
""
|
||||
].join("\n")
|
||||
);
|
||||
this.name = "LiveCollectionValidationError";
|
||||
}
|
||||
static is(error) {
|
||||
return error?.name === "LiveCollectionValidationError";
|
||||
}
|
||||
}
|
||||
class LiveCollectionCacheHintError extends LiveCollectionError {
|
||||
constructor(collection, entryId, error) {
|
||||
super(
|
||||
collection,
|
||||
[
|
||||
`**${String(collection)}${entryId ? ` \u2192 ${String(entryId)}` : ""}** returned an invalid cache hint.
|
||||
`,
|
||||
...error.errors.map((zodError) => ` **${zodError.path.join(".")}**: ${zodError.message}`),
|
||||
""
|
||||
].join("\n")
|
||||
);
|
||||
this.name = "LiveCollectionCacheHintError";
|
||||
}
|
||||
static is(error) {
|
||||
return error?.name === "LiveCollectionCacheHintError";
|
||||
}
|
||||
}
|
||||
export {
|
||||
LiveCollectionCacheHintError,
|
||||
LiveCollectionError,
|
||||
LiveCollectionValidationError,
|
||||
LiveEntryNotFoundError
|
||||
};
|
||||
15
node_modules/astro/dist/content/loaders/file.d.ts
generated
vendored
Normal file
15
node_modules/astro/dist/content/loaders/file.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { Loader } from './types.js';
|
||||
interface FileOptions {
|
||||
/**
|
||||
* the parsing function to use for this data
|
||||
* @default JSON.parse or yaml.load, depending on the extension of the file
|
||||
* */
|
||||
parser?: (text: string) => Record<string, Record<string, unknown>> | Array<Record<string, unknown>>;
|
||||
}
|
||||
/**
|
||||
* Loads entries from a JSON file. The file must contain an array of objects that contain unique `id` fields, or an object with string keys.
|
||||
* @param fileName The path to the JSON file to load, relative to the content directory.
|
||||
* @param options Additional options for the file loader
|
||||
*/
|
||||
export declare function file(fileName: string, options?: FileOptions): Loader;
|
||||
export {};
|
||||
102
node_modules/astro/dist/content/loaders/file.js
generated
vendored
Normal file
102
node_modules/astro/dist/content/loaders/file.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import { existsSync, promises as fs } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import yaml from "js-yaml";
|
||||
import toml from "smol-toml";
|
||||
import { FileGlobNotSupported, FileParserNotFound } from "../../core/errors/errors-data.js";
|
||||
import { AstroError } from "../../core/errors/index.js";
|
||||
import { posixRelative } from "../utils.js";
|
||||
function file(fileName, options) {
|
||||
if (fileName.includes("*")) {
|
||||
throw new AstroError(FileGlobNotSupported);
|
||||
}
|
||||
let parse = null;
|
||||
const ext = fileName.split(".").at(-1);
|
||||
if (ext === "json") {
|
||||
parse = JSON.parse;
|
||||
} else if (ext === "yml" || ext === "yaml") {
|
||||
parse = (text) => yaml.load(text, {
|
||||
filename: fileName
|
||||
});
|
||||
} else if (ext === "toml") {
|
||||
parse = toml.parse;
|
||||
}
|
||||
if (options?.parser) parse = options.parser;
|
||||
if (parse === null) {
|
||||
throw new AstroError({
|
||||
...FileParserNotFound,
|
||||
message: FileParserNotFound.message(fileName)
|
||||
});
|
||||
}
|
||||
async function syncData(filePath, { logger, parseData, store, config }) {
|
||||
let data;
|
||||
try {
|
||||
const contents = await fs.readFile(filePath, "utf-8");
|
||||
data = parse(contents);
|
||||
} catch (error) {
|
||||
logger.error(`Error reading data from ${fileName}`);
|
||||
logger.debug(error.message);
|
||||
return;
|
||||
}
|
||||
const normalizedFilePath = posixRelative(fileURLToPath(config.root), filePath);
|
||||
if (Array.isArray(data)) {
|
||||
if (data.length === 0) {
|
||||
logger.warn(`No items found in ${fileName}`);
|
||||
}
|
||||
logger.debug(`Found ${data.length} item array in ${fileName}`);
|
||||
store.clear();
|
||||
const idList = /* @__PURE__ */ new Set();
|
||||
for (const rawItem of data) {
|
||||
const id = (rawItem.id ?? rawItem.slug)?.toString();
|
||||
if (!id) {
|
||||
logger.error(`Item in ${fileName} is missing an id or slug field.`);
|
||||
continue;
|
||||
}
|
||||
if (idList.has(id)) {
|
||||
logger.warn(
|
||||
`Duplicate id "${id}" found in ${fileName}. Later items with the same id will overwrite earlier ones.`
|
||||
);
|
||||
}
|
||||
idList.add(id);
|
||||
const parsedData = await parseData({ id, data: rawItem, filePath });
|
||||
store.set({ id, data: parsedData, filePath: normalizedFilePath });
|
||||
}
|
||||
} else if (typeof data === "object") {
|
||||
const entries = Object.entries(data);
|
||||
logger.debug(`Found object with ${entries.length} entries in ${fileName}`);
|
||||
store.clear();
|
||||
for (const [id, rawItem] of entries) {
|
||||
if (id === "$schema" && typeof rawItem === "string") {
|
||||
continue;
|
||||
}
|
||||
const parsedData = await parseData({ id, data: rawItem, filePath });
|
||||
store.set({ id, data: parsedData, filePath: normalizedFilePath });
|
||||
}
|
||||
} else {
|
||||
logger.error(`Invalid data in ${fileName}. Must be an array or object.`);
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: "file-loader",
|
||||
load: async (context) => {
|
||||
const { config, logger, watcher } = context;
|
||||
logger.debug(`Loading data from ${fileName}`);
|
||||
const url = new URL(fileName, config.root);
|
||||
if (!existsSync(url)) {
|
||||
logger.error(`File not found: ${fileName}`);
|
||||
return;
|
||||
}
|
||||
const filePath = fileURLToPath(url);
|
||||
await syncData(filePath, context);
|
||||
watcher?.add(filePath);
|
||||
watcher?.on("change", async (changedPath) => {
|
||||
if (changedPath === filePath) {
|
||||
logger.info(`Reloading data from ${fileName}`);
|
||||
await syncData(filePath, context);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
file
|
||||
};
|
||||
31
node_modules/astro/dist/content/loaders/glob.d.ts
generated
vendored
Normal file
31
node_modules/astro/dist/content/loaders/glob.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { Loader } from './types.js';
|
||||
interface GenerateIdOptions {
|
||||
/** The path to the entry file, relative to the base directory. */
|
||||
entry: string;
|
||||
/** The base directory URL. */
|
||||
base: URL;
|
||||
/** The parsed, unvalidated data of the entry. */
|
||||
data: Record<string, unknown>;
|
||||
}
|
||||
interface GlobOptions {
|
||||
/** The glob pattern to match files, relative to the base directory */
|
||||
pattern: string | Array<string>;
|
||||
/** The base directory to resolve the glob pattern from. Relative to the root directory, or an absolute file URL. Defaults to `.` */
|
||||
base?: string | URL;
|
||||
/**
|
||||
* Function that generates an ID for an entry. Default implementation generates a slug from the entry path.
|
||||
* @returns The ID of the entry. Must be unique per collection.
|
||||
**/
|
||||
generateId?: (options: GenerateIdOptions) => string;
|
||||
}
|
||||
/**
|
||||
* Loads multiple entries, using a glob pattern to match files.
|
||||
* @param pattern A glob pattern to match files, relative to the content directory.
|
||||
*/
|
||||
export declare function glob(globOptions: GlobOptions): Loader;
|
||||
/** @private */
|
||||
export declare function glob(globOptions: GlobOptions & {
|
||||
/** @deprecated */
|
||||
_legacy?: true;
|
||||
}): Loader;
|
||||
export {};
|
||||
255
node_modules/astro/dist/content/loaders/glob.js
generated
vendored
Normal file
255
node_modules/astro/dist/content/loaders/glob.js
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
import { existsSync, promises as fs } from "node:fs";
|
||||
import { relative } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { bold, green } from "kleur/colors";
|
||||
import pLimit from "p-limit";
|
||||
import picomatch from "picomatch";
|
||||
import { glob as tinyglobby } from "tinyglobby";
|
||||
import { getContentEntryIdAndSlug, posixRelative } from "../utils.js";
|
||||
function generateIdDefault({ entry, base, data }) {
|
||||
if (data.slug) {
|
||||
return data.slug;
|
||||
}
|
||||
const entryURL = new URL(encodeURI(entry), base);
|
||||
const { slug } = getContentEntryIdAndSlug({
|
||||
entry: entryURL,
|
||||
contentDir: base,
|
||||
collection: ""
|
||||
});
|
||||
return slug;
|
||||
}
|
||||
function checkPrefix(pattern, prefix) {
|
||||
if (Array.isArray(pattern)) {
|
||||
return pattern.some((p) => p.startsWith(prefix));
|
||||
}
|
||||
return pattern.startsWith(prefix);
|
||||
}
|
||||
function glob(globOptions) {
|
||||
if (checkPrefix(globOptions.pattern, "../")) {
|
||||
throw new Error(
|
||||
"Glob patterns cannot start with `../`. Set the `base` option to a parent directory instead."
|
||||
);
|
||||
}
|
||||
if (checkPrefix(globOptions.pattern, "/")) {
|
||||
throw new Error(
|
||||
"Glob patterns cannot start with `/`. Set the `base` option to a parent directory or use a relative path instead."
|
||||
);
|
||||
}
|
||||
const generateId = globOptions?.generateId ?? generateIdDefault;
|
||||
const fileToIdMap = /* @__PURE__ */ new Map();
|
||||
return {
|
||||
name: "glob-loader",
|
||||
load: async ({ config, logger, watcher, parseData, store, generateDigest, entryTypes }) => {
|
||||
const renderFunctionByContentType = /* @__PURE__ */ new WeakMap();
|
||||
const untouchedEntries = new Set(store.keys());
|
||||
const isLegacy = globOptions._legacy;
|
||||
const emulateLegacyCollections = !config.legacy.collections;
|
||||
async function syncData(entry, base, entryType, oldId) {
|
||||
if (!entryType) {
|
||||
logger.warn(`No entry type found for ${entry}`);
|
||||
return;
|
||||
}
|
||||
const fileUrl = new URL(encodeURI(entry), base);
|
||||
const contents = await fs.readFile(fileUrl, "utf-8").catch((err) => {
|
||||
logger.error(`Error reading ${entry}: ${err.message}`);
|
||||
return;
|
||||
});
|
||||
if (!contents && contents !== "") {
|
||||
logger.warn(`No contents found for ${entry}`);
|
||||
return;
|
||||
}
|
||||
const { body, data } = await entryType.getEntryInfo({
|
||||
contents,
|
||||
fileUrl
|
||||
});
|
||||
const id = generateId({ entry, base, data });
|
||||
if (oldId && oldId !== id) {
|
||||
store.delete(oldId);
|
||||
}
|
||||
let legacyId;
|
||||
if (isLegacy) {
|
||||
const entryURL = new URL(encodeURI(entry), base);
|
||||
const legacyOptions = getContentEntryIdAndSlug({
|
||||
entry: entryURL,
|
||||
contentDir: base,
|
||||
collection: ""
|
||||
});
|
||||
legacyId = legacyOptions.id;
|
||||
}
|
||||
untouchedEntries.delete(id);
|
||||
const existingEntry = store.get(id);
|
||||
const digest = generateDigest(contents);
|
||||
const filePath2 = fileURLToPath(fileUrl);
|
||||
if (existingEntry && existingEntry.digest === digest && existingEntry.filePath) {
|
||||
if (existingEntry.deferredRender) {
|
||||
store.addModuleImport(existingEntry.filePath);
|
||||
}
|
||||
if (existingEntry.assetImports?.length) {
|
||||
store.addAssetImports(existingEntry.assetImports, existingEntry.filePath);
|
||||
}
|
||||
fileToIdMap.set(filePath2, id);
|
||||
return;
|
||||
}
|
||||
const relativePath2 = posixRelative(fileURLToPath(config.root), filePath2);
|
||||
const parsedData = await parseData({
|
||||
id,
|
||||
data,
|
||||
filePath: filePath2
|
||||
});
|
||||
if (entryType.getRenderFunction) {
|
||||
if (isLegacy && data.layout) {
|
||||
logger.error(
|
||||
`The Markdown "layout" field is not supported in content collections in Astro 5. Ignoring layout for ${JSON.stringify(entry)}. Enable "legacy.collections" if you need to use the layout field.`
|
||||
);
|
||||
}
|
||||
let render = renderFunctionByContentType.get(entryType);
|
||||
if (!render) {
|
||||
render = await entryType.getRenderFunction(config);
|
||||
renderFunctionByContentType.set(entryType, render);
|
||||
}
|
||||
let rendered = void 0;
|
||||
try {
|
||||
rendered = await render?.({
|
||||
id,
|
||||
data,
|
||||
body,
|
||||
filePath: filePath2,
|
||||
digest
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(`Error rendering ${entry}: ${error.message}`);
|
||||
}
|
||||
store.set({
|
||||
id,
|
||||
data: parsedData,
|
||||
body,
|
||||
filePath: relativePath2,
|
||||
digest,
|
||||
rendered,
|
||||
assetImports: rendered?.metadata?.imagePaths,
|
||||
legacyId
|
||||
});
|
||||
} else if ("contentModuleTypes" in entryType) {
|
||||
store.set({
|
||||
id,
|
||||
data: parsedData,
|
||||
body,
|
||||
filePath: relativePath2,
|
||||
digest,
|
||||
deferredRender: true,
|
||||
legacyId
|
||||
});
|
||||
} else {
|
||||
store.set({ id, data: parsedData, body, filePath: relativePath2, digest, legacyId });
|
||||
}
|
||||
fileToIdMap.set(filePath2, id);
|
||||
}
|
||||
const baseDir = globOptions.base ? new URL(globOptions.base, config.root) : config.root;
|
||||
if (!baseDir.pathname.endsWith("/")) {
|
||||
baseDir.pathname = `${baseDir.pathname}/`;
|
||||
}
|
||||
const filePath = fileURLToPath(baseDir);
|
||||
const relativePath = relative(fileURLToPath(config.root), filePath);
|
||||
const exists = existsSync(baseDir);
|
||||
if (!exists) {
|
||||
logger.warn(`The base directory "${fileURLToPath(baseDir)}" does not exist.`);
|
||||
}
|
||||
const files = await tinyglobby(globOptions.pattern, {
|
||||
cwd: fileURLToPath(baseDir),
|
||||
expandDirectories: false
|
||||
});
|
||||
if (exists && files.length === 0) {
|
||||
logger.warn(
|
||||
`No files found matching "${globOptions.pattern}" in directory "${relativePath}"`
|
||||
);
|
||||
return;
|
||||
}
|
||||
function configForFile(file) {
|
||||
const ext = file.split(".").at(-1);
|
||||
if (!ext) {
|
||||
logger.warn(`No extension found for ${file}`);
|
||||
return;
|
||||
}
|
||||
return entryTypes.get(`.${ext}`);
|
||||
}
|
||||
const limit = pLimit(10);
|
||||
const skippedFiles = [];
|
||||
const contentDir = new URL("content/", config.srcDir);
|
||||
function isInContentDir(file) {
|
||||
const fileUrl = new URL(file, baseDir);
|
||||
return fileUrl.href.startsWith(contentDir.href);
|
||||
}
|
||||
const configFiles = new Set(
|
||||
["config.js", "config.ts", "config.mjs"].map((file) => new URL(file, contentDir).href)
|
||||
);
|
||||
function isConfigFile(file) {
|
||||
const fileUrl = new URL(file, baseDir);
|
||||
return configFiles.has(fileUrl.href);
|
||||
}
|
||||
await Promise.all(
|
||||
files.map((entry) => {
|
||||
if (isConfigFile(entry)) {
|
||||
return;
|
||||
}
|
||||
if (!emulateLegacyCollections && isInContentDir(entry)) {
|
||||
skippedFiles.push(entry);
|
||||
return;
|
||||
}
|
||||
return limit(async () => {
|
||||
const entryType = configForFile(entry);
|
||||
await syncData(entry, baseDir, entryType);
|
||||
});
|
||||
})
|
||||
);
|
||||
const skipCount = skippedFiles.length;
|
||||
if (skipCount > 0) {
|
||||
const patternList = Array.isArray(globOptions.pattern) ? globOptions.pattern.join(", ") : globOptions.pattern;
|
||||
logger.warn(
|
||||
`The glob() loader cannot be used for files in ${bold("src/content")} when legacy mode is enabled.`
|
||||
);
|
||||
if (skipCount > 10) {
|
||||
logger.warn(
|
||||
`Skipped ${green(skippedFiles.length)} files that matched ${green(patternList)}.`
|
||||
);
|
||||
} else {
|
||||
logger.warn(`Skipped the following files that matched ${green(patternList)}:`);
|
||||
skippedFiles.forEach((file) => logger.warn(`\u2022 ${green(file)}`));
|
||||
}
|
||||
}
|
||||
untouchedEntries.forEach((id) => store.delete(id));
|
||||
if (!watcher) {
|
||||
return;
|
||||
}
|
||||
watcher.add(filePath);
|
||||
const matchesGlob = (entry) => !entry.startsWith("../") && picomatch.isMatch(entry, globOptions.pattern);
|
||||
const basePath = fileURLToPath(baseDir);
|
||||
async function onChange(changedPath) {
|
||||
const entry = posixRelative(basePath, changedPath);
|
||||
if (!matchesGlob(entry)) {
|
||||
return;
|
||||
}
|
||||
const entryType = configForFile(changedPath);
|
||||
const baseUrl = pathToFileURL(basePath);
|
||||
const oldId = fileToIdMap.get(changedPath);
|
||||
await syncData(entry, baseUrl, entryType, oldId);
|
||||
logger.info(`Reloaded data from ${green(entry)}`);
|
||||
}
|
||||
watcher.on("change", onChange);
|
||||
watcher.on("add", onChange);
|
||||
watcher.on("unlink", async (deletedPath) => {
|
||||
const entry = posixRelative(basePath, deletedPath);
|
||||
if (!matchesGlob(entry)) {
|
||||
return;
|
||||
}
|
||||
const id = fileToIdMap.get(deletedPath);
|
||||
if (id) {
|
||||
store.delete(id);
|
||||
fileToIdMap.delete(deletedPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
glob
|
||||
};
|
||||
3
node_modules/astro/dist/content/loaders/index.d.ts
generated
vendored
Normal file
3
node_modules/astro/dist/content/loaders/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export { file } from './file.js';
|
||||
export { glob } from './glob.js';
|
||||
export * from './types.js';
|
||||
7
node_modules/astro/dist/content/loaders/index.js
generated
vendored
Normal file
7
node_modules/astro/dist/content/loaders/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { file } from "./file.js";
|
||||
import { glob } from "./glob.js";
|
||||
export * from "./types.js";
|
||||
export {
|
||||
file,
|
||||
glob
|
||||
};
|
||||
65
node_modules/astro/dist/content/loaders/types.d.ts
generated
vendored
Normal file
65
node_modules/astro/dist/content/loaders/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import type { FSWatcher } from 'vite';
|
||||
import type { ZodSchema } from 'zod';
|
||||
import type { AstroIntegrationLogger } from '../../core/logger/core.js';
|
||||
import type { AstroConfig } from '../../types/public/config.js';
|
||||
import type { LiveDataCollection, LiveDataEntry } from '../../types/public/content.js';
|
||||
import type { RenderedContent } from '../data-store.js';
|
||||
import type { DataStore, MetaStore } from '../mutable-data-store.js';
|
||||
export type { DataStore, MetaStore };
|
||||
export interface ParseDataOptions<TData extends Record<string, unknown>> {
|
||||
/** The ID of the entry. Unique per collection */
|
||||
id: string;
|
||||
/** The raw, unvalidated data of the entry */
|
||||
data: TData;
|
||||
/** An optional file path, where the entry represents a local file. */
|
||||
filePath?: string;
|
||||
}
|
||||
export interface LoaderContext {
|
||||
/** The unique name of the collection */
|
||||
collection: string;
|
||||
/** A database to store the actual data */
|
||||
store: DataStore;
|
||||
/** A simple KV store, designed for things like sync tokens */
|
||||
meta: MetaStore;
|
||||
logger: AstroIntegrationLogger;
|
||||
/** Astro config, with user config and merged defaults */
|
||||
config: AstroConfig;
|
||||
/** Validates and parses the data according to the collection schema */
|
||||
parseData<TData extends Record<string, unknown>>(props: ParseDataOptions<TData>): Promise<TData>;
|
||||
/** Renders markdown content to HTML and metadata */
|
||||
renderMarkdown(content: string): Promise<RenderedContent>;
|
||||
/** Generates a non-cryptographic content digest. This can be used to check if the data has changed */
|
||||
generateDigest(data: Record<string, unknown> | string): string;
|
||||
/** When running in dev, this is a filesystem watcher that can be used to trigger updates */
|
||||
watcher?: FSWatcher;
|
||||
/** If the loader has been triggered by an integration, this may optionally contain extra data set by that integration */
|
||||
refreshContextData?: Record<string, unknown>;
|
||||
}
|
||||
export interface Loader {
|
||||
/** Unique name of the loader, e.g. the npm package name */
|
||||
name: string;
|
||||
/** Do the actual loading of the data */
|
||||
load: (context: LoaderContext) => Promise<void>;
|
||||
/** Optionally, define the schema of the data. Will be overridden by user-defined schema */
|
||||
schema?: ZodSchema | Promise<ZodSchema> | (() => ZodSchema | Promise<ZodSchema>);
|
||||
}
|
||||
export interface LoadEntryContext<TEntryFilter = never> {
|
||||
filter: TEntryFilter extends never ? {
|
||||
id: string;
|
||||
} : TEntryFilter;
|
||||
}
|
||||
export interface LoadCollectionContext<TCollectionFilter = unknown> {
|
||||
filter?: TCollectionFilter;
|
||||
}
|
||||
export interface LiveLoader<TData extends Record<string, any> = Record<string, unknown>, TEntryFilter extends Record<string, any> | never = never, TCollectionFilter extends Record<string, any> | never = never, TError extends Error = Error> {
|
||||
/** Unique name of the loader, e.g. the npm package name */
|
||||
name: string;
|
||||
/** Load a single entry */
|
||||
loadEntry: (context: LoadEntryContext<TEntryFilter>) => Promise<LiveDataEntry<TData> | undefined | {
|
||||
error: TError;
|
||||
}>;
|
||||
/** Load a collection of entries */
|
||||
loadCollection: (context: LoadCollectionContext<TCollectionFilter>) => Promise<LiveDataCollection<TData> | {
|
||||
error: TError;
|
||||
}>;
|
||||
}
|
||||
0
node_modules/astro/dist/content/loaders/types.js
generated
vendored
Normal file
0
node_modules/astro/dist/content/loaders/types.js
generated
vendored
Normal file
Reference in New Issue
Block a user