Skip to content

Commit

Permalink
Replace spaces with hyphens in tag names (#74)
Browse files Browse the repository at this point in the history
Obsidian tags cannot contain spaces so we need to replace them with a
supported character. We use the hyphen.

https://help.obsidian.md/Editing+and+formatting/Tags#Tag+format
  • Loading branch information
jparise authored Oct 31, 2024
1 parent 97bdce1 commit 0605b69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export async function syncNotes(
frontmatter['url'] = article.url;
frontmatter['date'] = formatTimestamp(article.time);
frontmatter['tags'] = (article.tags.length > 0)
? article.tags.map((tag) => tag.name) : undefined;
? article.tags.map((tag) => tag.name.replace(/\s+/, '-'))
: undefined;
if (article.pubtime) {
frontmatter['pubdate'] = formatTimestamp(article.pubtime);
}
Expand Down

0 comments on commit 0605b69

Please sign in to comment.