Skip to content

Commit

Permalink
Use brut context (#56)
Browse files Browse the repository at this point in the history
* Use local version of brut

* Update page template variables

* Define a notes collection

This also migrates publishDate to published_date

* Replace processNote buildScript with a processContext function

The bulk of the diff is removing the buildScript from frontmatter in all notes

* Replace getNotesLastFive buildScript by context preprocessing and mustache section

* Replace getNotes buildScript by a mustache section

* Remove unused deps

* Bump brut
  • Loading branch information
robinmetral authored Aug 11, 2024
1 parent 1b9cb35 commit 84e149e
Show file tree
Hide file tree
Showing 222 changed files with 1,312 additions and 2,444 deletions.
24 changes: 23 additions & 1 deletion brut.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
export default {};
export default {
collections: ["notes"],
processContext: (context) => {
const notesWithFormattedDate = context.notes.map((note) => {
const formattedDate = new Date(
note.frontmatter.published_date
).toLocaleDateString("en-US", {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
});
// add the formatted date under frontmatter as published_date_string
// we keep published_date because we need it for the HTML time element's datetime attribute
note.frontmatter.published_date_string = formattedDate;
return note;
});
const notesLastTen = notesWithFormattedDate.slice(0, 10);
context.notes = notesWithFormattedDate;
context.notes_last_ten = notesLastTen;
return context;
},
};
1 change: 0 additions & 1 deletion drafts/food-links.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "Food links"
template: page
buildScript: "/scripts/processNote.js"
---

I don't know where else to put these.
Expand Down
1 change: 0 additions & 1 deletion drafts/garden.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "Garden"
template: page
buildScript: "/scripts/processNote.js"
---

# Web
Expand Down
3 changes: 1 addition & 2 deletions drafts/nucleaire.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
title: "Nucléaire"
categories:
- name:
publishDate: "2023-12-24"
published_date: "2023-12-24"
template: page
buildScript: "/scripts/processNote.js"
---

Sur Janco et Le monde sans fin:
Expand Down
Loading

0 comments on commit 84e149e

Please sign in to comment.