forked from guanyixi/pose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
50 lines (43 loc) · 1.78 KB
/
.eleventy.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
43
44
45
46
47
48
49
50
const eleventySass = require("@11tyrocks/eleventy-plugin-sass-lightningcss");
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("./src/img/");
eleventyConfig.addPassthroughCopy("./src/js/");
eleventyConfig.addPlugin(eleventySass);
eleventyConfig.addFilter('upcomingEvents', function(events) {
const currentDate = new Date();
const currentDateString = Number(currentDate.toISOString().slice(0,10).replace(/-/g, ''));
return events.filter(event => {
const filename = event.filePathStem.split('/').pop();
const eventDate = Number(filename.slice(0,8));
return eventDate >= currentDateString;
});
});
eleventyConfig.addFilter('pastEvents', function(events) {
const currentDate = new Date();
const currentDateString = Number(currentDate.toISOString().slice(0,10).replace(/-/g, ''));
// return events.filter(event => {
// const filename = event.filePathStem.split('/').pop();
// const eventDate = Number(filename.slice(0,8));
// return eventDate < currentDateString;
// });
// Filter past events
const pastEvents = events.filter(event => {
const filename = event.filePathStem.split('/').pop();
const eventDate = Number(filename.slice(0,8)); // Extract event date from the filename
return eventDate < currentDateString;
});
// Sort the past events in reverse order (most recent first)
return pastEvents.sort((a, b) => {
const aDate = Number(a.filePathStem.split('/').pop().slice(0,8));
const bDate = Number(b.filePathStem.split('/').pop().slice(0,8));
return bDate - aDate; // Reverse order sorting (descending)
});
});
return {
pathPrefix: "/pose/", // The base path in github
dir: {
input: "src",
output: "public",
},
};
};