Skip to content

Commit

Permalink
fix(gatsby): Reuse readPageData (#33595)
Browse files Browse the repository at this point in the history
Co-authored-by: gatsbybot <[email protected]>
Co-authored-by: LekoArts <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2021
1 parent ad32926 commit 2a9ee7c
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/gatsby/src/utils/worker/child/render-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
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 {
readWebpackStats,
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,
Expand Down Expand Up @@ -53,21 +53,6 @@ function clearCaches(): void {
clearAssetsMappingCache()
}

async function readPageData(
publicDir: string,
pagePath: string
): Promise<IPageDataWithQueryResult> {
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<IResourcesForTemplate> {
Expand Down

0 comments on commit 2a9ee7c

Please sign in to comment.