Skip to content

Commit 295c02a

Browse files
committed
fix: escape colons that otherwise mess up the markdown frontmatter
1 parent 0f9fb80 commit 295c02a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pull.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ async function getPagesRecursively(
143143
}
144144

145145
async function outputPage(page: NotionPage) {
146+
console.log(`Reading Page ${page.context}/${page.nameOrTitle}`);
147+
146148
const blocks = (await page.getBlockChildren()).results;
147149

148150
await outputImages(blocks);
149151

150152
currentSidebarPosition++;
151153

152-
console.log(`Reading Page ${page.context}/${page.nameOrTitle}`);
153-
154154
if (page.type === PageType.DatabasePage && page.status !== "Publish") {
155155
console.log(
156156
notice(`Skipping page because status is not Publish: ${page.nameOrTitle}`)
@@ -167,9 +167,9 @@ async function outputPage(page: NotionPage) {
167167
// console.log(JSON.stringify(mdBlocks, null, 2));
168168
// }
169169
let frontmatter = "---\n";
170-
frontmatter += `title: ${page.nameOrTitle}\n`;
170+
frontmatter += `title: ${page.nameOrTitle.replaceAll(":", ":")}\n`; // markdown can't handle the ":" here
171171
frontmatter += `sidebar_position: ${currentSidebarPosition}\n`;
172-
frontmatter += `slug: ${page.slug ?? ""}\n`;
172+
frontmatter += `slug: ${page.slug.replaceAll(":", "-") ?? ""}\n`; // markdown can't handle the ":" or ":" here
173173
if (page.keywords) frontmatter += `keywords: [${page.keywords}]\n`;
174174

175175
frontmatter += "---\n";

0 commit comments

Comments
 (0)