Skip to content

Commit

Permalink
fix: better colon handling in slug
Browse files Browse the repository at this point in the history
  • Loading branch information
hatton committed Jul 26, 2022
1 parent cb19125 commit b4a0a39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/NotionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export class NotionPage {
if (explicitSlug) return explicitSlug;
return encodeURIComponent(
this.nameOrTitle.toLowerCase().replaceAll(" ", "-")
);
)
.replaceAll("%3A", "-")
.replaceAll("--", "-");
}
public get keywords(): string | undefined {
return this.getPlainTextProperty("Keywords", "");
Expand Down
2 changes: 1 addition & 1 deletion src/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async function outputPage(page: NotionPage) {
let frontmatter = "---\n";
frontmatter += `title: ${page.nameOrTitle.replaceAll(":", ":")}\n`; // markdown can't handle the ":" here
frontmatter += `sidebar_position: ${currentSidebarPosition}\n`;
frontmatter += `slug: ${page.slug.replaceAll(":", "-") ?? ""}\n`; // markdown can't handle the ":" or ":" here
frontmatter += `slug: ${page.slug ?? ""}\n`;
if (page.keywords) frontmatter += `keywords: [${page.keywords}]\n`;

frontmatter += "---\n";
Expand Down

0 comments on commit b4a0a39

Please sign in to comment.