Skip to content

Commit 8358a4e

Browse files
author
Sergei Orlov
committed
✨ Add support for Remark and MDX integration
💥 Rename markdown property to markdownString
1 parent c2a1163 commit 8358a4e

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

gatsby-node.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { getPages } = require("./src/notion-api/get-pages")
22
const { getNotionPageMD } = require("./src/transformers/get-page-md")
33
const { getNotionPageProperties } = require("./src/transformers/get-page-properties")
44
const { getNotionPageTitle } = require("./src/transformers/get-page-title")
5+
const YAML = require("yaml")
56

67
const NODE_TYPE = "Notion"
78

@@ -15,20 +16,28 @@ exports.sourceNodes = async (
1516
)
1617

1718
pages.forEach((page) => {
19+
const title = getNotionPageTitle(page)
20+
const properties = getNotionPageProperties(page)
21+
const markdown = "---\n"
22+
.concat(YAML.stringify({ title, ...properties }))
23+
.concat("\n---\n\n")
24+
.concat(getNotionPageMD(page))
25+
1826
actions.createNode({
1927
id: createNodeId(`${NODE_TYPE}-${page.id}`),
20-
title: getNotionPageTitle(page),
21-
properties: getNotionPageProperties(page),
28+
title,
29+
properties,
2230
archived: page.archived,
2331
createdAt: page.created_time,
2432
updatedAt: page.last_edited_time,
25-
markdown: getNotionPageMD(page),
33+
markdownString: markdown,
2634
raw: page,
2735
parent: null,
2836
children: [],
2937
internal: {
3038
type: NODE_TYPE,
31-
content: JSON.stringify(page),
39+
mediaType: "text/markdown",
40+
content: markdown,
3241
contentDigest: createContentDigest(page),
3342
},
3443
})

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"readme": "https://github.com/orlowdev/gatsby-source-notion-api#readme",
3535
"dependencies": {
3636
"node-fetch": "^2.6.1",
37-
"or-pipets": "^1.0.1"
37+
"or-pipets": "^1.0.1",
38+
"yaml": "^1.10.2"
3839
},
3940
"devDependencies": {
4041
"ava": "^3.15.0",

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -3334,6 +3334,11 @@ yallist@^4.0.0:
33343334
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
33353335
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
33363336

3337+
yaml@^1.10.2:
3338+
version "1.10.2"
3339+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
3340+
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
3341+
33373342
yargs-parser@^18.1.2:
33383343
version "18.1.3"
33393344
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"

0 commit comments

Comments
 (0)