-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_feeds.ts
99 lines (96 loc) · 3.08 KB
/
_feeds.ts
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import feed from 'lume/plugins/feed.ts';
import { DateTimeFormat, formatTemporalDate } from './src/_lume-plugins/temporal-date.ts';
import { type Book } from './api/model/book.ts';
export const feeds = () => (site: any) => {
site.use(feed({
output: ['feed.xml', 'feed.json'],
query: 'type=note|post|recipe|book',
sort: 'finishedAt=desc date=desc',
info: {
title: "Johan's feed",
description: 'Aggregated feed of all activity on johan.im',
generator: false,
},
items: {
title: (t) => {
switch (t.type) {
case 'note':
return formatTemporalDate(t.date, DateTimeFormat.HumanTime, t.timezone);
default:
return t.title;
}
},
description: (t) => {
switch (t.type) {
case 'post':
return '=excerpt';
case 'book':
return bookDescriptionOf(t);
default:
return t.excerpt || t.description;
}
},
content: (t) => {
switch (t.type) {
case 'book':
return t.notes || 'No notes';
default:
return t.children || t.content;
}
},
},
}))
.use(feed({
output: ['micro.xml', 'micro.json'],
query: 'type=note',
info: {
title: '=titles.micro',
generator: false,
},
items: {
title: (post) => formatTemporalDate(post.date, DateTimeFormat.HumanTime, post.timezone),
},
}))
.use(feed({
output: ['writings.xml', 'writings.json'],
query: 'type=post',
info: {
title: '=titles.writings',
generator: false,
},
items: {
description: '=excerpt',
},
}))
.use(feed({
output: ['reading.xml', 'reading.json'],
query: 'type=book',
sort: 'finishedAt=desc',
info: {
title: '=titles.reading',
generator: false,
},
items: {
description: bookDescriptionOf,
content: (book) => {
if (book.notes) return book.notes;
return 'No notes';
},
updated: '=finishedAt',
},
}))
.use(feed({
output: ['recipes.xml', 'recipes.json'],
query: 'type=recipe',
info: {
title: '=titles.recipes',
generator: false,
},
}));
};
const bookDescriptionOf = (book: Book) => {
if (book.dropped) return 'Book dropped';
if (book.paused) return 'Book paused';
if (!book.finished) return 'Currently reading';
return 'Finished reading';
};