Skip to content

Commit

Permalink
Use publish date for events instead of update. (#72)
Browse files Browse the repository at this point in the history
* Cleanup unused reference to draft

* Show published date for events, not last update
  • Loading branch information
zephraph authored Oct 4, 2024
1 parent f70e5c2 commit bdbdd74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 8 additions & 5 deletions packages/my-remark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@ export const myRemark: RemarkPlugin = () => {
}

if (fm.published) {
const publishedLabel = {
let dateLabel = {
type: "html" as const,
value: `<p><sup ${
fm.updated ? `title="Published on ${fm.published}"` : ""
}>${fm.updated ?? fm.published}</sup></p>`,
value: `<p><sup>${fm.published}</sup></p>`,
};

// If the document is associated with an event, skip showing the updated date
if (fm.updated && !fm.tags?.includes("events")) {
dateLabel.value = `<p><sup title="Published on ${fm.published}">${fm.updated}</sup></p>`;
}

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);
}
}
};
Expand Down
4 changes: 0 additions & 4 deletions scripts/ob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bdbdd74

Please sign in to comment.