Skip to content

Commit aa404d4

Browse files
committed
feat: render bookmark as link
1 parent c4e004b commit aa404d4

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The following [Notion API block object types](https://developers.notion.com/refe
4141
| Video | ❌ Missing | |
4242
| File | ❌ Missing | |
4343
| PDF | ❌ Missing | |
44-
| Bookmark | ❌ Missing | |
44+
| Bookmark | ✅ Yes | use a caption as a link name | |
4545
| Equation | ❌ Missing | |
4646
| Divider | ✅ Yes | |
4747
| Table Of Contents | ❌ not planned | static site generators have their own ToC implementations |

src/BlockRenderer.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,28 @@ export class BlockRenderer {
102102
return { lines: "---" };
103103
case "child_database":
104104
const msg = `<!-- included database ${block.id} -->\n`;
105-
const db = await this.deferredRenderer.renderChildDatabase(block.id, context.linkResolver);
105+
const db = await this.deferredRenderer.renderChildDatabase(
106+
block.id,
107+
context.linkResolver
108+
);
106109
return { lines: msg + db.markdown };
107110
case "synced_block":
108111
// nothing to render, only the contents of the synced block are relevant
109112
// however, these are children nöpcl, and thus retrieved by recursion in RecusivveBodyRenderer
110113
return null;
114+
case "bookmark":
115+
const caption = block.bookmark.caption;
116+
let title = block.bookmark.url;
117+
if (caption) {
118+
if (caption.length > 0)
119+
title = await this.richText.renderPlainText(caption);
120+
}
121+
return {
122+
lines: `[${title}](${block.bookmark.url})`,
123+
};
111124
case "toggle":
112125
case "child_page":
113126
case "embed":
114-
case "bookmark":
115127
case "video":
116128
case "file":
117129
case "pdf":
@@ -145,10 +157,7 @@ export class BlockRenderer {
145157
}
146158
}
147159

148-
async renderImage(
149-
block: ImageBlock,
150-
assets: AssetWriter
151-
): Promise<string> {
160+
async renderImage(block: ImageBlock, assets: AssetWriter): Promise<string> {
152161
const url = this.parseUrl(block.image);
153162

154163
const imageFile = await assets.download(url, block.id);

0 commit comments

Comments
 (0)