Skip to content

Commit d891f8b

Browse files
authored
Merge branch 'main' into patch-1
2 parents 463a1bb + 5fa039a commit d891f8b

File tree

210 files changed

+3818
-1196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+3818
-1196
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ This opens a local server at `http://localhost:8080/` and watches for changes to
2222
# To Dos
2323

2424
1. Replace autoprefixer and cssnano with lightningcss
25+
26+
# Guidelines for Development
27+
28+
1. While 11ty allows for shortcodes and other customizations, sticking with Liquid fundamentals is preferred for interoperability.

eleventy.config.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
const path = require('path');
22

33
const Image = require('@11ty/eleventy-img');
4-
const markdownIt = require("markdown-it");
54

65
const setupCollections = require('./lib/collections');
6+
const setupSessions = require('./lib/sessions');
77
const setupFeed = require('./lib/feed');
8+
const markdown = require('./lib/markdown');
9+
10+
const { UTCDate } = require('@date-fns/utc');
811

912
module.exports = (config) => {
1013
setupCollections(config);
14+
//setupSessions(config);
1115
setupFeed(config);
1216

1317
/*
@@ -43,7 +47,7 @@ module.exports = (config) => {
4347
sizes,
4448
classes = "") {
4549
let metadata = await Image(src, {
46-
widths: [300, 600],
50+
widths: [180, 300, 600],
4751
formats: ["webp"],
4852
outputDir,
4953
urlPath,
@@ -66,19 +70,26 @@ module.exports = (config) => {
6670
return Image.generateHTML(metadata, imageAttributes);
6771
});
6872

73+
config.addPairedShortcode("markdown", function(content = "") {
74+
return markdown.render(content);
75+
});
76+
6977
/*
7078
Filters
7179
*/
7280
config.addFilter("markdown", function(content = "") {
73-
let markdown = markdownIt({
74-
html: true,
75-
breaks: true,
76-
linkify: true
77-
});
78-
7981
return markdown.render(content);
8082
});
8183

84+
// https://www.11ty.dev/docs/dates/#dates-off-by-one-day
85+
config.addFilter("utcDate", function(date) {
86+
return new UTCDate(date);
87+
});
88+
89+
config.addFilter("find", function find(collection = [], slug = "") {
90+
return collection.find(item => item.fileSlug === slug);
91+
});
92+
8293
/*
8394
Misc configuration
8495
*/
@@ -87,6 +98,8 @@ module.exports = (config) => {
8798
excerpt_separator: "<!-- excerpt -->"
8899
});
89100

101+
config.setLibrary("md", markdown);
102+
90103
return {
91104
dir: {
92105
input: "src",
@@ -96,7 +109,6 @@ module.exports = (config) => {
96109

97110
// Use Liquid for templating
98111
// https://www.11ty.dev/docs/languages/liquid/
99-
htmlTemplateEngine: "liquid",
100-
markdownTemplateEngine: "liquid"
112+
htmlTemplateEngine: "liquid"
101113
}
102114
};

lib/markdown.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const markdownIt = require("markdown-it");
2+
const markdownItAnchor = require("markdown-it-anchor");
3+
4+
const markdown = markdownIt({
5+
html: true,
6+
breaks: true,
7+
linkify: true
8+
})
9+
.use(markdownItAnchor, {
10+
// The level option defines the minimum level of headings to apply anchors to.
11+
// 1 applies to all headings. 2 will apply to h2 and below, etc.
12+
level: 1,
13+
// The slugify option is a function that transforms the heading text into a URL fragment identifier.
14+
slugify: markdownItAnchor.defaults.slugify
15+
});
16+
17+
module.exports = markdown;

lib/sessions.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const fs = require('fs');
2+
const yaml = require('yaml');
3+
4+
module.exports = function(config) {
5+
config.addCollection("sessionsByDateAndTime", function(collectionApi) {
6+
// Get all sessions
7+
let sessions = collectionApi.getFilteredByGlob("src/_content/schedule/{tutorials,talks,sprints}/*.md");
8+
9+
// Read and parse manual.yaml
10+
const manualContent = fs.readFileSync('src/_content/schedule/manual.yaml', 'utf8');
11+
const manualData = yaml.parse(manualContent);
12+
13+
// Merge manual sessions with existing sessions
14+
sessions = sessions.concat(manualData);
15+
16+
// Filter out hidden sessions
17+
sessions = sessions.filter(session => !(session.data?.hidden || session.hidden));
18+
19+
// Manually set session URLs
20+
/*
21+
sessions = sessions.map(session => {
22+
const sessionData = session.data || session;
23+
if (sessionData.permalink) {
24+
sessionData.url = sessionData.permalink;
25+
} else {
26+
sessionData.url = `/talks/${sessionData.slug}/`;
27+
}
28+
29+
return session;
30+
});
31+
*/
32+
33+
// Group sessions by date and time
34+
const sessionsByDateAndTime = sessions.reduce((acc, session) => {
35+
const sessionData = session.data || session;
36+
37+
let dateObj = new Date(sessionData.datetime);
38+
let date = dateObj.toISOString().split('T')[0];
39+
let start = dateObj.toISOString();
40+
let end = sessionData.end_datetime;
41+
42+
if (!acc[date]) {
43+
acc[date] = []
44+
}
45+
46+
let slotKey = `${start}-${end}`;
47+
let slot = acc[date].find(slot => `${slot.start}-${slot.end}` === slotKey);
48+
49+
if (!slot) {
50+
slot = {
51+
start: start,
52+
end: end,
53+
sessions: []
54+
};
55+
acc[date].push(slot);
56+
}
57+
58+
slot.sessions.push(sessionData);
59+
60+
return acc;
61+
}, {});
62+
63+
// Sort sessions by start date and then end date
64+
for (let date in sessionsByDateAndTime) {
65+
sessionsByDateAndTime[date].sort((a, b) => {
66+
let startComparison = new Date(a.start) - new Date(b.start);
67+
if (startComparison !== 0) {
68+
return startComparison;
69+
} else {
70+
return new Date(a.end) - new Date(b.end);
71+
}
72+
});
73+
}
74+
75+
return sessionsByDateAndTime;
76+
});
77+
};

0 commit comments

Comments
 (0)