Skip to content

Commit 9a80401

Browse files
TylerBarnesvladar
authored andcommitted
fix(gatsby): single page node manifest accuracy (#33642)
* expect the manifest has the correct foundPageBy * ensure foundPageBy is accurate when there's only 1 relevant page (cherry picked from commit 4b6d04b)
1 parent f90c61c commit 9a80401

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

integration-tests/node-manifest/__tests__/create-node-manifest.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
5353

5454
expect(manifestFileContents.node.id).toBe(`1`)
5555
expect(manifestFileContents.page.path).toBe(`/one`)
56+
expect(manifestFileContents.foundPageBy).toBe(`ownerNodeId`)
5657
})
5758

5859
it(`Creates an accurate node manifest when ownerNodeId isn't present but there's a matching "id" in pageContext`, async () => {
5960
const manifestFileContents = await getManifestContents(2)
6061

6162
expect(manifestFileContents.node.id).toBe(`2`)
6263
expect(manifestFileContents.page.path).toBe(`/two`)
64+
expect(manifestFileContents.foundPageBy).toBe(`context.id`)
6365
})
6466

6567
if (gatsbyCommandName === `build`) {
@@ -74,6 +76,7 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
7476
manifestFileContents.page.path
7577
)
7678
).toBe(true)
79+
expect(manifestFileContents.foundPageBy).toBe(`queryTracking`)
7780
})
7881

7982
// this doesn't work in gatsby develop since page-data.json files aren't written out
@@ -93,12 +96,14 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
9396

9497
expect(manifestFileContents.node.id).toBe(`4`)
9598
expect(manifestFileContents.page.path).toBe(null)
99+
expect(manifestFileContents.foundPageBy).toBe(`none`)
96100
})
97101

98102
it(`Creates a Node manifest for filesystem routes`, async () => {
99103
const manifestFileContents = await getManifestContents(`filesystem-1`)
100104

101105
expect(manifestFileContents.node.id).toBe(`filesystem-1`)
102106
expect(manifestFileContents.page.path).toBe(`/filesystem-1/`)
107+
expect(manifestFileContents.foundPageBy).toBe(`filesystem-route-api`)
103108
})
104109
})

packages/gatsby/src/utils/node-manifest.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ async function findPageOwnedByNodeId({ nodeId }: { nodeId: string }): Promise<{
7070

7171
let foundPageBy: FoundPageBy = pagePath ? `queryTracking` : `none`
7272

73-
// but if we have more than one page where this node shows up
74-
// we need to try to be more specific
75-
if (pagePathSetOrMap && pagePathSetOrMap.size > 1) {
73+
if (pagePathSetOrMap) {
7674
let ownerPagePath: string | undefined
7775
let foundOwnerNodeId = false
7876

0 commit comments

Comments
 (0)