From 2a9ee7c8cd1ba9994f10e911f6b140144796f3f9 Mon Sep 17 00:00:00 2001 From: Tony Hallett Date: Thu, 4 Nov 2021 13:16:01 +0000 Subject: [PATCH] fix(gatsby): Reuse readPageData (#33595) Co-authored-by: gatsbybot Co-authored-by: LekoArts --- .../src/utils/worker/child/render-html.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/gatsby/src/utils/worker/child/render-html.ts b/packages/gatsby/src/utils/worker/child/render-html.ts index cfadd3476ea52..3b0726a5e8d90 100644 --- a/packages/gatsby/src/utils/worker/child/render-html.ts +++ b/packages/gatsby/src/utils/worker/child/render-html.ts @@ -3,7 +3,7 @@ import fs from "fs-extra" import Bluebird from "bluebird" import * as path from "path" -import { generateHtmlPath, fixedPagePath } from "gatsby-core-utils" +import { generateHtmlPath } from "gatsby-core-utils" import { truncate } from "lodash" import { @@ -11,7 +11,7 @@ import { getScriptsAndStylesForTemplate, clearCache as clearAssetsMappingCache, } from "../../client-assets-for-template" -import type { IPageDataWithQueryResult } from "../../page-data" +import { IPageDataWithQueryResult, readPageData } from "../../page-data" import type { IRenderHtmlResult } from "../../../commands/build-html" import { clearStaticQueryCaches, @@ -53,21 +53,6 @@ function clearCaches(): void { clearAssetsMappingCache() } -async function readPageData( - publicDir: string, - pagePath: string -): Promise { - const filePath = join( - publicDir, - `page-data`, - fixedPagePath(pagePath), - `page-data.json` - ) - const rawPageData = await fs.readFile(filePath, `utf-8`) - - return JSON.parse(rawPageData) -} - async function doGetResourcesForTemplate( pageData: IPageDataWithQueryResult ): Promise {