Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion _events/_events.11tydata.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ export default {
layout: "event.11ty.tsx",
eleventyComputed: {
date(data) {
if (data.event != null) return;

const res = DateTime.fromFormat(data.date, "yyyy-MM-dd HH:mm", {
zone: "America/New_York",
}).toJSDate();
data.page.date = res;
return res;
},
excerpt(data) {
const res = data.page.rawInput.trim().split("\n\n")[0];
let content = data.page.rawInput;
if (data.event != null) content = data.event.content ?? "";

const res = content.trim().split("\n\n")[0];
data.page.excerpt = res;
return res;
},
Expand Down
11 changes: 11 additions & 0 deletions _events/_ical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
pagination:
data: ical_events
size: 1
alias: event
permalink: "{{ event.url }}"
eleventyComputed:
title: "{{ event.data.title }}"
---

{{ event.content }}
5 changes: 4 additions & 1 deletion _includes/event-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ <h3>
</h3>
📆 <time datetime="{{ event.date | date_or_utc: '%Y-%m-%d %H:%M:%S %z' }}">
{{ event.date | all_time_zones: event.data.time_zones }}
</time><br>
</time>
{%- if event.data.locations -%}
<br>
📍 {% include locations.html%}
{%- endif -%}
</div>
</article>
2 changes: 1 addition & 1 deletion _includes/events.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% assign berlin_events = site.data.berlin_events %}
{% assign nl_events = site.data.nl_events %}
{% assign events = site.events | concat: nl_events | concat: berlin_events | date_sort | filter_tags: include.tags %}
{% assign events = site.events | concat: ical_events | concat: nl_events | concat: berlin_events | date_sort | filter_tags: include.tags %}
{% assign future_events = events | where_future: site.time %}
{% assign past_events = events | where_past: site.time %}

Expand Down
49 changes: 47 additions & 2 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as jsxRuntime from "hastscript/jsx-runtime";
import { DateTime } from "luxon";
import markdownIt from "markdown-it";
import markdownItAnchor from "markdown-it-anchor";
import ical from "node-ical";
import rehypeSlug from "rehype-slug";
import YAML from "yaml";

Expand Down Expand Up @@ -67,6 +68,7 @@ export default async (cfg) => {
cfg.addDataExtension("yml", YAML.parse);
cfg.addDataExtension("yaml", YAML.parse);

// fixme(maximsmol): calendar events do not get loaded into RSS
const getRssConfig = (collection, name) => ({
type: "atom",
outputPath: `/feed/${collection}.xml`,
Expand Down Expand Up @@ -240,6 +242,47 @@ export default async (cfg) => {
});
cfg.addTemplateFormats("mdx");

const fetchCalendar = async () => {
const base =
"https://dev.techworkerscoalition.org/nextcloud/remote.php/dav/public-calendars/EHFzzZQXSQoS3f5w/?export";
const data = await ical.fromURL(base);

if (data == null) throw new Error("failed to load calendar data");

const events = [];
for (const [, entry] of Object.entries(data)) {
if (entry == null) continue;
if (entry.type !== "VEVENT") continue;

const img =
entry.attach?.val != null &&
entry.attach?.params.FMTTYPE.startsWith("image/")
? new URL(entry.attach.val, base)
: undefined;

const start = DateTime.fromJSDate(entry.start, {
zone: entry.start.tz,
});
// todo(maximsmol): deal with recurring events
// todo(maximsmol): extract image from content
events.push({
// todo(maximsmol): use a timezone-aware datetime?
date: start.toJSDate(),
url: `/events/${entry.uid}/`,
data: {
title: entry.summary,
time_zones: entry.start.tz != null ? [entry.start.tz] : undefined,
image: img?.href,
locations: entry.location != null ? [entry.location] : undefined,
},
content:
entry.description != null ? md.render(entry.description) : undefined,
});
}

cfg.addGlobalData("ical_events", events);
};

const remoteDataSrcs = [
{
data: "berlin_press",
Expand All @@ -254,7 +297,7 @@ export default async (cfg) => {
url: "https://techwerkers.nl/en/twc-global/index.yaml",
},
];
const deferred = [];
const deferred = [fetchCalendar()];
for (const x of remoteDataSrcs)
deferred.push(
(async () => {
Expand All @@ -265,7 +308,9 @@ export default async (cfg) => {
});
const data = YAML.parse(await req.text());

console.log(`Fetched: ${x.data} from ${x.url}`);
console.log(
`Fetched ${data.length} ${x.data} items from from ${x.url}`,
);

cfg.addGlobalData(x.data, data);
})(),
Expand Down
2 changes: 2 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export default defineConfig([
tseslint.configs.stylisticTypeChecked,
],
rules: {
"@typescript-eslint/no-confusing-void-expression": "off",

"@typescript-eslint/consistent-type-definitions": ["error", "type"],
},
languageOptions: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"luxon": "^3.7.2",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.2.0",
"node-ical": "^0.25.2",
"rehype-slug": "^6.0.0",
"tsx": "^4.21.0",
"typescript-eslint": "^8.54.0",
Expand Down
31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.