Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/keystatic/src/reader/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ export type MinimalFs = {
fileExists(path: string): Promise<boolean>;
};

const decoder = new TextDecoder();

async function getAllEntries(
parent: string,
fsReader: MinimalFs
Expand Down Expand Up @@ -350,7 +352,7 @@ const readItem = cache(async function readItem(
}
if (schema.formKind === 'content') {
contentFieldPathsToEagerlyResolve?.push(path);
return async () => {
return async (options?: { raw: boolean }) => {
let content: undefined | Uint8Array;
const filename =
pathWithArrayFieldSlugs.join('/') + schema.contentExtension;
Expand All @@ -362,6 +364,10 @@ const readItem = cache(async function readItem(
undefined;
}

if (options?.raw) {
return decoder.decode(content);
}

return schema.reader.parse(value, { content });
};
}
Expand Down