Skip to content

Commit 9beb748

Browse files
authored
Merge pull request #21 from LandonSchropp/main
Add support for column lists and columns
2 parents 10a7880 + ead58c2 commit 9beb748

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ Untouched contents of whatever Notion API returned.
214214

215215
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.
216216

217+
Since there's not semantic HTML analog for column lists and columns, these Notion blocks are transformed to `<ColumnList>` and `<Column>` components in the markdown. To customize these components, you can write custom components for these and [include them in your `MDXProvider`](https://www.gatsbyjs.com/docs/mdx/importing-and-using-components#make-components-available-globally-as-shortcodes).
218+
217219
## Attaching images via "Files" property
218220

219221
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:

src/transformers/notion-block-to-markdown.js

+27
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,33 @@ exports.notionBlockToMarkdown = (block, lowerTitleLevel) => {
133133
return `${EOL_MD}---${EOL_MD}`
134134
}
135135

136+
// Column List
137+
if (block.type == "column_list") {
138+
return [
139+
EOL_MD,
140+
"<ColumnList>",
141+
EOL_MD,
142+
markdown,
143+
EOL_MD,
144+
"</ColumnList>",
145+
EOL_MD
146+
].join("")
147+
}
148+
149+
// Column
150+
if (block.type == "column") {
151+
return [
152+
"<Column>",
153+
EOL_MD,
154+
EOL_MD,
155+
markdown,
156+
EOL_MD,
157+
EOL_MD,
158+
"</Column>",
159+
EOL_MD
160+
].join("")
161+
}
162+
136163
// Unsupported types.
137164
// TODO: Add support for callouts, internal video, and files
138165
return [EOL_MD, `<!-- This block type '${block.type}' is not supported yet. -->`, EOL_MD].join("")

0 commit comments

Comments
 (0)