feat(exporter): add auto-generated description to frontmatter
This commit is contained in:
10
main.js
10
main.js
@@ -173,19 +173,21 @@ class AstroPostExporter extends Plugin {
|
||||
const modified = file.stat && file.stat.mtime ? file.stat.mtime : Date.now();
|
||||
const title = file.basename;
|
||||
|
||||
const includePubDate = !hasFrontmatterKey(content, "pubDate");
|
||||
const includeDescription = !hasFrontmatterKey(content, "description");
|
||||
const pubDate = moment(created).format(this.settings.dateFormat);
|
||||
const modifiedDate = moment(modified).format(this.settings.dateFormat);
|
||||
|
||||
const frontmatterLines = [
|
||||
`title: "${escapeYamlString(title)}"`,
|
||||
...(includePubDate ? [`pubDate: "${pubDate}"`] : []),
|
||||
`${this.settings.modifiedDateKey}: "${modifiedDate}"`
|
||||
...(includeDescription ? [`description: "${escapeYamlString(title)}"`] : []),
|
||||
`pubDate: ${pubDate}`,
|
||||
`${this.settings.modifiedDateKey}: ${modifiedDate}`
|
||||
];
|
||||
|
||||
const keysToReplace = [
|
||||
"title",
|
||||
...(includePubDate ? ["pubDate"] : []),
|
||||
...(includeDescription ? ["description"] : []),
|
||||
"pubDate",
|
||||
this.settings.modifiedDateKey
|
||||
];
|
||||
return upsertFrontmatter(content, frontmatterLines, keysToReplace);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"id": "astro-post-exporter",
|
||||
"name": "Astro Post Exporter",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"minAppVersion": "1.4.0",
|
||||
"description": "Export Obsidian notes to an Astro posts folder with frontmatter.",
|
||||
"author": "astro-chiri",
|
||||
"author": "Logic",
|
||||
"isDesktopOnly": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user