-
Notifications
You must be signed in to change notification settings - Fork 0
/
brut.config.js
42 lines (41 loc) · 1.27 KB
/
brut.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import rehypeShiki from "@shikijs/rehype";
export default {
collections: ["notes"],
rehypePlugins: [
[
rehypeShiki,
{
themes: {
light: "vitesse-light",
dark: "vitesse-dark",
},
},
],
],
processContext: (context) => {
const notesWithFormattedDate = context.notes.map((note) => {
const publishedDate = new Date(note.frontmatter.published_date);
// 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 = publishedDate.toLocaleDateString(
"en-US",
{
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
}
);
note.frontmatter.published_date_iso = publishedDate.toISOString();
return note;
});
context.notes = notesWithFormattedDate;
// last 10 notes for homepage
context.notes_last_ten = context.notes.slice(0, 10);
// last 30 notes for feed
context.notes_last_thirty = context.notes.slice(0, 30);
// ISO date for Atom feed
context.updated_date_iso = context.notes[0].frontmatter.published_date_iso;
return context;
},
};