Skip to content

Commit ed3de50

Browse files
author
Sergei Orlov
committed
🚑 Docs updated for propsToFrontmatter, Files property, and lowerTitleLevel
1 parent 31528e3 commit ed3de50

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ plugins: [
8080
options: {
8181
token: `$INTEGRATION_TOKEN`,
8282
databaseId: `$DATABASE_ID`,
83+
propsToFrontmatter: true,
84+
lowerTitleLevel: true,
8385
},
8486
},
8587
// ...
@@ -97,6 +99,14 @@ Integration token.
9799
The identifier of the database you want to get pages from. The integration identified by provided
98100
token must have access to the database with given id.
99101

102+
`propsToFrontmatter` [boolean][defaults to **true**]
103+
104+
Put Notion page props to Markdown frontmatter. If you set this to **false**, you will need to query `notion` to get page props.
105+
106+
`lowerTitleLevel` [boolean][defaults to **true**]
107+
108+
Push headings one level down. # becomes ##, ## becomes ###, ### becomes ####. Notion is limited to only 3 levels of heading. You can create ####, #####, etc. - they will not be reflected in Notion, but they will work properly in the Markdown output. Is **true** by default.
109+
100110
## How to query for nodes
101111

102112
You can query for pages with `notion` or grab all of them with `allNotion`. The raw content of the
@@ -114,7 +124,10 @@ query {
114124
children
115125
internal
116126
title
117-
properties
127+
properties {
128+
My_Prop_1
129+
My_Prop_2
130+
}
118131
archived
119132
createdAt
120133
updatedAt
@@ -201,6 +214,39 @@ Untouched contents of whatever Notion API returned.
201214

202215
Markdown contents of the page. Limited by blocks currently supported by Notion API. Unsupported blocks turn into HTML comments specifying that Notion marked this block as non-supported.
203216

217+
## Attaching images via "Files" property
218+
219+
If you want to turn images attached through the "Files" property into file nodes that you can use with gatsby-image, you need to attach remote file nodes to the "Files" property. In the example below, the `propsToFrontmatter` is set to **true** and the **_Hero Image_** Files property is used for images:
220+
221+
```javascript
222+
// ./gatsby-node.js
223+
exports.onCreateNode = async ({ node, actions: { createNode }, createNodeId, getCache }) => {
224+
if (node.internal.type === "MarkdownRemark") {
225+
for (let i = 0; i < node.frontmatter["Hero Image"].length; i++) {
226+
const name = node.frontmatter["Hero Image"][i].name
227+
228+
if (!name) {
229+
continue
230+
}
231+
232+
if (name.startsWith("http")) {
233+
const fileNode = await createRemoteFileNode({
234+
url: name,
235+
parentNodeId: node.id,
236+
createNode,
237+
createNodeId,
238+
getCache,
239+
})
240+
241+
if (fileNode) {
242+
node.frontmatter["Hero Image"][i].remoteImage___NODE = fileNode.id
243+
}
244+
}
245+
}
246+
}
247+
}
248+
```
249+
204250
## Current state
205251

206252
- Due to the fact that Notion API only appeared recently, and it is still in beta, some blocks are

0 commit comments

Comments
 (0)