From bdbdd7467846891a4877e5fb30672a71aa495d97 Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Thu, 3 Oct 2024 20:18:37 -0400 Subject: [PATCH] Use `publish` date for events instead of `update`. (#72) * Cleanup unused reference to draft * Show published date for events, not last update --- packages/my-remark/index.ts | 13 ++++++++----- scripts/ob.ts | 4 ---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/my-remark/index.ts b/packages/my-remark/index.ts index bde18c2..3383af7 100644 --- a/packages/my-remark/index.ts +++ b/packages/my-remark/index.ts @@ -53,19 +53,22 @@ export const myRemark: RemarkPlugin = () => { } if (fm.published) { - const publishedLabel = { + let dateLabel = { type: "html" as const, - value: `

${fm.updated ?? fm.published}

`, + value: `

${fm.published}

`, }; + // If the document is associated with an event, skip showing the updated date + if (fm.updated && !fm.tags?.includes("events")) { + dateLabel.value = `

${fm.updated}

`; + } + const firstHeadingIndex = root.children.findIndex( (node) => node.type === "heading" && node.depth === 1 ); if (firstHeadingIndex !== -1) { - root.children.splice(firstHeadingIndex + 1, 0, publishedLabel); + root.children.splice(firstHeadingIndex + 1, 0, dateLabel); } } }; diff --git a/scripts/ob.ts b/scripts/ob.ts index 7b18edd..dee39a2 100644 --- a/scripts/ob.ts +++ b/scripts/ob.ts @@ -75,10 +75,6 @@ async function publishNote(path: string) { fm.updated = today; await updateFrontmatter(path, fm); } - if (fm.draft === false) { - delete fm.draft; - await updateFrontmatter(path, fm); - } } fm.title ??= await extractH1(path);