Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {

expect(manifestFileContents.node.id).toBe(`1`)
expect(manifestFileContents.page.path).toBe(`/one`)
expect(manifestFileContents.foundPageBy).toBe(`ownerNodeId`)
})

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

expect(manifestFileContents.node.id).toBe(`2`)
expect(manifestFileContents.page.path).toBe(`/two`)
expect(manifestFileContents.foundPageBy).toBe(`context.id`)
})

if (gatsbyCommandName === `build`) {
Expand All @@ -74,6 +76,7 @@ describe(`Node Manifest API in "gatsby ${gatsbyCommandName}"`, () => {
manifestFileContents.page.path
)
).toBe(true)
expect(manifestFileContents.foundPageBy).toBe(`queryTracking`)
})

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

expect(manifestFileContents.node.id).toBe(`4`)
expect(manifestFileContents.page.path).toBe(null)
expect(manifestFileContents.foundPageBy).toBe(`none`)
})

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

expect(manifestFileContents.node.id).toBe(`filesystem-1`)
expect(manifestFileContents.page.path).toBe(`/filesystem-1/`)
expect(manifestFileContents.foundPageBy).toBe(`filesystem-route-api`)
})
})
4 changes: 1 addition & 3 deletions packages/gatsby/src/utils/node-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ async function findPageOwnedByNodeId({ nodeId }: { nodeId: string }): Promise<{

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

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

Expand Down