Skip to content

Commit 9cdb197

Browse files
author
Sergei Orlov
committed
✨ Add access to some page properties
* archived * createdAt * updatedAt * title
1 parent 8cc4065 commit 9cdb197

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

gatsby-node.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,27 @@ exports.sourceNodes = async (
1212
pages: await getPages(pluginOptions, reporter),
1313
}
1414

15-
data.pages.forEach((page) =>
15+
data.pages.forEach((page) => {
16+
const properties = Object.keys(page.properties).reduce(
17+
(acc, key) =>
18+
acc.concat([
19+
{
20+
key,
21+
...page.properties[key],
22+
},
23+
]),
24+
[],
25+
)
26+
27+
const title = properties.find((property) => property.type == "title").title[0].plain_text
28+
1629
createNode({
1730
id: createNodeId(`${NODE_TYPE}-${page.id}`),
31+
title,
32+
properties,
33+
archived: page.archived,
34+
createdAt: page.created_time,
35+
updatedAt: page.last_edited_time,
1836
raw: page,
1937
parent: null,
2038
children: [],
@@ -23,6 +41,6 @@ exports.sourceNodes = async (
2341
content: JSON.stringify(page),
2442
contentDigest: createContentDigest(page),
2543
},
26-
}),
27-
)
44+
})
45+
})
2846
}

0 commit comments

Comments
 (0)