Skip to content

Commit

Permalink
fix(previews): restore dataRaw document field
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Nov 15, 2021
1 parent 40b6546 commit 3ab85ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ type NormalizeDocumentConfig<Value extends prismicT.PrismicDocument> =
export type NormalizedDocumentValue<
Value extends prismicT.PrismicDocument = prismicT.PrismicDocument,
> = Omit<Value, "alternate_languages" | "data"> & {
__typename: string;
_previewable: string;
prismicId: string;
alternate_languages: NormalizedAlternateLanguagesValue;
data: NormalizedValueMap<Value["data"]>;
} & gatsby.NodeInput & {
__typename: string;
_previewable: string;
prismicId: string;
};
dataRaw: Value["data"];
} & gatsby.NodeInput;

export const document = <Value extends prismicT.PrismicDocument>(
config: NormalizeDocumentConfig<Value>,
Expand All @@ -47,6 +47,7 @@ export const document = <Value extends prismicT.PrismicDocument>(
}),
url: prismicH.asLink(config.value, config.linkResolver),
data: {},
dataRaw: config.value.data,
};

if (Object.keys(config.value.data).length > 0) {
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-source-prismic/test/runtime-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test("normalizes documents", (t) => {
t.is(typeof normalizedDocument.id, "string");
t.is(normalizedDocument.prismicId, document.id);

t.is(normalizedDocument.dataRaw, document.data);

t.is(normalizedDocument.internal.type, "PrismicSynergies");
t.is(typeof normalizedDocument.internal.contentDigest, "string");
});
Expand Down

0 comments on commit 3ab85ea

Please sign in to comment.