Skip to content

Commit f8d42b1

Browse files
committed
feat: support page component URIs in page tree rendering
1 parent 819ce3e commit f8d42b1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/gatsby-cli/src/reporter/loggers/ink/components/pageTree.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React, { ReactElement, useContext } from "react"
33
import { Box, Text, BoxProps, Spacer } from "ink"
44
import path from "path"
5+
import { getPathToLayoutComponent } from "gatsby-core-utils"
56
import StoreStateContext from "../context"
67
import {
78
generatePageTree,
@@ -117,7 +118,8 @@ const ConnectedPageTree: React.FC = function ConnectedPageTree() {
117118
const componentWithPages = new Map<string, IComponentWithPageModes>()
118119

119120
for (const { componentPath, pages } of state.pageTree!.components.values()) {
120-
const pagesByMode = {
121+
const layoutComponent = getPathToLayoutComponent(componentPath)
122+
const pagesByMode = componentWithPages.get(layoutComponent) || {
121123
SSG: new Set<string>(),
122124
DSG: new Set<string>(),
123125
SSR: new Set<string>(),
@@ -128,8 +130,7 @@ const ConnectedPageTree: React.FC = function ConnectedPageTree() {
128130

129131
pagesByMode[gatsbyPage!.mode].add(pagePath)
130132
})
131-
132-
componentWithPages.set(componentPath, pagesByMode)
133+
componentWithPages.set(layoutComponent, pagesByMode)
133134
}
134135

135136
for (const {

packages/gatsby-cli/src/reporter/loggers/yurnalist/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
IComponentWithPageModes,
1818
} from "../../../util/generate-page-tree"
1919
import { IRenderPageArgs } from "../../types"
20+
import { getPathToLayoutComponent } from "gatsby-core-utils"
2021

2122
interface IYurnalistActivities {
2223
[activityId: string]: {
@@ -34,7 +35,9 @@ function generatePageTreeToConsole(
3435
const root = state.root
3536
const componentWithPages = new Map<string, IComponentWithPageModes>()
3637
for (const { componentPath, pages } of state.components.values()) {
37-
const pagesByMode = {
38+
const layoutComponent = getPathToLayoutComponent(componentPath)
39+
const relativePath = path.posix.relative(root, layoutComponent)
40+
const pagesByMode = componentWithPages.get(relativePath) || {
3841
SSG: new Set<string>(),
3942
DSG: new Set<string>(),
4043
SSR: new Set<string>(),
@@ -46,10 +49,7 @@ function generatePageTreeToConsole(
4649
pagesByMode[gatsbyPage!.mode].add(pagePath)
4750
})
4851

49-
componentWithPages.set(
50-
path.posix.relative(root, componentPath),
51-
pagesByMode
52-
)
52+
componentWithPages.set(relativePath, pagesByMode)
5353
}
5454

5555
for (const {

0 commit comments

Comments
 (0)