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 modified = file.stat && file.stat.mtime ? file.stat.mtime : Date.now();
|
||||||
const title = file.basename;
|
const title = file.basename;
|
||||||
|
|
||||||
const includePubDate = !hasFrontmatterKey(content, "pubDate");
|
const includeDescription = !hasFrontmatterKey(content, "description");
|
||||||
const pubDate = moment(created).format(this.settings.dateFormat);
|
const pubDate = moment(created).format(this.settings.dateFormat);
|
||||||
const modifiedDate = moment(modified).format(this.settings.dateFormat);
|
const modifiedDate = moment(modified).format(this.settings.dateFormat);
|
||||||
|
|
||||||
const frontmatterLines = [
|
const frontmatterLines = [
|
||||||
`title: "${escapeYamlString(title)}"`,
|
`title: "${escapeYamlString(title)}"`,
|
||||||
...(includePubDate ? [`pubDate: "${pubDate}"`] : []),
|
...(includeDescription ? [`description: "${escapeYamlString(title)}"`] : []),
|
||||||
`${this.settings.modifiedDateKey}: "${modifiedDate}"`
|
`pubDate: ${pubDate}`,
|
||||||
|
`${this.settings.modifiedDateKey}: ${modifiedDate}`
|
||||||
];
|
];
|
||||||
|
|
||||||
const keysToReplace = [
|
const keysToReplace = [
|
||||||
"title",
|
"title",
|
||||||
...(includePubDate ? ["pubDate"] : []),
|
...(includeDescription ? ["description"] : []),
|
||||||
|
"pubDate",
|
||||||
this.settings.modifiedDateKey
|
this.settings.modifiedDateKey
|
||||||
];
|
];
|
||||||
return upsertFrontmatter(content, frontmatterLines, keysToReplace);
|
return upsertFrontmatter(content, frontmatterLines, keysToReplace);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"id": "astro-post-exporter",
|
"id": "astro-post-exporter",
|
||||||
"name": "Astro Post Exporter",
|
"name": "Astro Post Exporter",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"minAppVersion": "1.4.0",
|
"minAppVersion": "1.4.0",
|
||||||
"description": "Export Obsidian notes to an Astro posts folder with frontmatter.",
|
"description": "Export Obsidian notes to an Astro posts folder with frontmatter.",
|
||||||
"author": "astro-chiri",
|
"author": "Logic",
|
||||||
"isDesktopOnly": true
|
"isDesktopOnly": true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user