@allons-y/course-kit 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/scripts/deck.js +3 -34
- package/assets/styles/base.css +135 -2
- package/assets/styles/print.css +8 -1
- package/components/practice/practice-worksheet.webc +1 -5
- package/components/site/book-appointment.webc +26 -0
- package/components/site/course-now.webc +7 -0
- package/components/site/glossary.webc +0 -5
- package/components/site/instructor.webc +3 -3
- package/components/site/masthead.webc +11 -1
- package/components/site/nav-links.webc +16 -0
- package/components/site/schedule-overview.webc +204 -17
- package/components/site/schedule-weeks.webc +24 -51
- package/components/site/site-footer.webc +16 -2
- package/components/ui/codepen-embed.webc +2 -5
- package/components/ui/download-button.webc +3 -3
- package/components/ui/table-rubric.webc +2 -1
- package/examples/starter/_data/schedule.json +1 -1
- package/layouts/deck.webc +0 -4
- package/layouts/document.webc +2 -1
- package/layouts/lesson.webc +8 -12
- package/lib/check.js +23 -1
- package/lib/copy.js +1 -3
- package/lib/data/glossary.js +2 -3
- package/lib/data/site.js +2 -1
- package/lib/filters.js +64 -27
- package/lib/lesson-materials.js +3 -2
- package/lib/pdf.js +7 -1
- package/lib/plugin.js +3 -1
- package/lib/postcss.js +3 -1
- package/package.json +2 -1
- package/schemas/course.schema.json +5 -0
- package/schemas/instructor.schema.json +20 -0
- package/schemas/worksheet.schema.json +6 -1
- package/assets/scripts/theme-restore.js +0 -17
package/lib/copy.js
CHANGED
|
@@ -105,7 +105,6 @@ export const COPY_DEFAULTS = {
|
|
|
105
105
|
noClass: "No class — {reason}",
|
|
106
106
|
substitution: "Runs a {weekday} schedule",
|
|
107
107
|
dueKeyLabel: "Key to due items",
|
|
108
|
-
graded: "graded",
|
|
109
108
|
notGraded: "not graded",
|
|
110
109
|
dueKindTest: "Test",
|
|
111
110
|
dueKindGraded: "Graded",
|
|
@@ -158,7 +157,6 @@ export const COPY_DEFAULTS = {
|
|
|
158
157
|
hint: "Space reveals · arrows move",
|
|
159
158
|
defShown: "Definition shown for {term}",
|
|
160
159
|
symbols: "Symbols",
|
|
161
|
-
glossary: "Glossary",
|
|
162
160
|
courseGlossary: "Course glossary",
|
|
163
161
|
slidesOnly: "Slides only",
|
|
164
162
|
finalExam: "Final exam",
|
|
@@ -336,6 +334,7 @@ export const COPY_DEFAULTS = {
|
|
|
336
334
|
instructor: "Instructor",
|
|
337
335
|
contact: "Contact",
|
|
338
336
|
blogUrl: "Blog: {url}",
|
|
337
|
+
bookAnAppointment: "Book an appointment",
|
|
339
338
|
},
|
|
340
339
|
codepenEmbed: {
|
|
341
340
|
theCode: "The code",
|
|
@@ -354,7 +353,6 @@ export const COPY_DEFAULTS = {
|
|
|
354
353
|
slides: "Slides",
|
|
355
354
|
previousSlide: "Previous slide",
|
|
356
355
|
nextSlide: "Next slide",
|
|
357
|
-
cycleColorTheme: "Cycle color theme",
|
|
358
356
|
toggleFullscreen: "Toggle fullscreen",
|
|
359
357
|
},
|
|
360
358
|
document: {
|
package/lib/data/glossary.js
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
|
|
9
|
-
import { dateFormat } from "@allons-y/dashly/filters/dates";
|
|
10
9
|
import matter from "gray-matter";
|
|
11
10
|
import markdownIt from "markdown-it";
|
|
12
11
|
|
|
13
12
|
import { COPY_DEFAULTS } from "../copy.js";
|
|
14
|
-
import { fullDate } from "../filters.js";
|
|
13
|
+
import { formatDate, fullDate } from "../filters.js";
|
|
15
14
|
|
|
16
15
|
const DECK = /^week-(\d+)-day-(\d+)(?:-[\w-]+)?\.md$/;
|
|
17
16
|
const TEST = /^Test (\d+)$/;
|
|
@@ -221,7 +220,7 @@ export function buildGlossary({ lessons: meetings, schedule, course, slidesDir,
|
|
|
221
220
|
label: `Week ${deck.week} · ${meeting.weekday}`,
|
|
222
221
|
order: deck.week * 100 + deck.day,
|
|
223
222
|
date: meeting.date,
|
|
224
|
-
when:
|
|
223
|
+
when: formatDate(meeting.date, MONTH_DAY),
|
|
225
224
|
deck: title,
|
|
226
225
|
});
|
|
227
226
|
|
package/lib/data/site.js
CHANGED
|
@@ -35,7 +35,7 @@ const originSlug = () => {
|
|
|
35
35
|
/**
|
|
36
36
|
* Site-wide metadata, the global `site`. URL resolution reads the CONTEXT, URL
|
|
37
37
|
* and DEPLOY_PRIME_URL variables; see the README.
|
|
38
|
-
* @param {{ course: object, pkg?: object, institution?: { name?: string, timezone?: string, lms?: string }, site?: { description?: string, keywords?: string, language?: string }, env?: NodeJS.ProcessEnv }} data
|
|
38
|
+
* @param {{ course: object, pkg?: object, institution?: { name?: string, timezone?: string, lms?: string, sourceUrl?: string }, site?: { description?: string, keywords?: string, language?: string }, env?: NodeJS.ProcessEnv }} data
|
|
39
39
|
* @returns {object}
|
|
40
40
|
*/
|
|
41
41
|
export function resolveSite({ course, pkg = {}, institution = {}, site = {}, env = process.env }) {
|
|
@@ -59,6 +59,7 @@ export function resolveSite({ course, pkg = {}, institution = {}, site = {}, env
|
|
|
59
59
|
institution: name,
|
|
60
60
|
timezone: institution.timezone || "UTC",
|
|
61
61
|
lms: institution.lms ?? "Brightspace",
|
|
62
|
+
sourceUrl: institution.sourceUrl ?? "",
|
|
62
63
|
keywords: site.keywords ?? [name, course.code, course.name, "syllabus", "course schedule", "class resources"].filter(Boolean).join(", "),
|
|
63
64
|
url,
|
|
64
65
|
hostname,
|
package/lib/filters.js
CHANGED
|
@@ -8,11 +8,42 @@ import { dateFormat, longDate, shortDate } from "@allons-y/dashly/filters/dates"
|
|
|
8
8
|
import { COPY_DEFAULTS } from "./copy.js";
|
|
9
9
|
import { projectMilestones } from "./data/project.js";
|
|
10
10
|
|
|
11
|
-
const FULL = { weekday: "long", month: "long", day: "numeric", year: "numeric" };
|
|
12
11
|
const MONTH_DAY = { month: "long", day: "numeric" };
|
|
13
12
|
|
|
14
|
-
/**
|
|
15
|
-
export const
|
|
13
|
+
/** The date formats a course can change with the `dateFormats` option: a locale and the two named formats, as `Intl.DateTimeFormat` options. */
|
|
14
|
+
export const DATE_FORMAT_DEFAULTS = Object.freeze({
|
|
15
|
+
locale: "en-US",
|
|
16
|
+
full: Object.freeze({ weekday: "long", month: "long", day: "numeric", year: "numeric" }),
|
|
17
|
+
short: Object.freeze({ weekday: "short", month: "short", day: "numeric" }),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
let formats = DATE_FORMAT_DEFAULTS;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Set the course's date formats; anything left out keeps its default, and no argument restores the defaults. Called once by `courseKit`
|
|
24
|
+
* with its `dateFormats` option, so every helper below, and the data files that import them, read the same formats.
|
|
25
|
+
* @param {{ locale?: string, full?: Intl.DateTimeFormatOptions, short?: Intl.DateTimeFormatOptions }} [options]
|
|
26
|
+
*/
|
|
27
|
+
export const setDateFormats = (options = {}) => {
|
|
28
|
+
formats = { ...DATE_FORMAT_DEFAULTS, ...options };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Format an ISO date in the course's locale. Every date the kit writes goes through here.
|
|
33
|
+
* @param {string | number | Date} value
|
|
34
|
+
* @param {Intl.DateTimeFormatOptions} options
|
|
35
|
+
* @returns {string | number | Date} the formatted text, or `value` itself when it is empty or not a date
|
|
36
|
+
*/
|
|
37
|
+
export const formatDate = (value, options) => dateFormat(value, options, formats.locale);
|
|
38
|
+
|
|
39
|
+
/** The long form, for prose and for places with room: "Monday, August 19, 2026". */
|
|
40
|
+
export const fullDate = (iso) => formatDate(iso, formats.full);
|
|
41
|
+
|
|
42
|
+
/** The short form, for a narrow table column or a chip: "Wed, Aug 19". The year is left out; a term sits inside one. */
|
|
43
|
+
export const compactDate = (iso) => formatDate(iso, formats.short);
|
|
44
|
+
|
|
45
|
+
/** A date in the long form, or the short one when `style` is `"short"`. Anything else is the long form. */
|
|
46
|
+
export const dateIn = (iso, style) => (style === "short" ? compactDate(iso) : fullDate(iso));
|
|
16
47
|
|
|
17
48
|
/**
|
|
18
49
|
* Format an ISO date span: "October 17–20, 2026" within one month,
|
|
@@ -20,12 +51,13 @@ export const fullDate = (iso) => dateFormat(iso, FULL);
|
|
|
20
51
|
*/
|
|
21
52
|
export const dateRange = (start, end) =>
|
|
22
53
|
start.slice(0, 7) === end.slice(0, 7)
|
|
23
|
-
? `${
|
|
24
|
-
: `${
|
|
54
|
+
? `${formatDate(start, MONTH_DAY)}–${Number(end.slice(8, 10))}, ${end.slice(0, 4)}`
|
|
55
|
+
: `${formatDate(start, MONTH_DAY)} – ${formatDate(end, MONTH_DAY)}, ${end.slice(0, 4)}`;
|
|
25
56
|
|
|
26
57
|
/**
|
|
27
58
|
* Display string for a course's exam slot ({ date, start, end }):
|
|
28
|
-
* "Tuesday, December 8, 2026, 9:
|
|
59
|
+
* "Tuesday, December 8, 2026, 9:00AM–12:00PM", or "Tue, Dec 8, 9:00AM–12:00PM"
|
|
60
|
+
* when `style` is `"short"`.
|
|
29
61
|
*/
|
|
30
62
|
/**
|
|
31
63
|
* Canonical clock time: `timeOfDay("11:59 pm")` -> "11:59PM". Normalizes
|
|
@@ -47,9 +79,9 @@ export const timeOfDay = (value) => {
|
|
|
47
79
|
return normalized.every(Boolean) ? normalized.join("–") : value;
|
|
48
80
|
};
|
|
49
81
|
|
|
50
|
-
export const examSlot = (finalExam) =>
|
|
82
|
+
export const examSlot = (finalExam, style) =>
|
|
51
83
|
finalExam
|
|
52
|
-
? `${
|
|
84
|
+
? `${dateIn(finalExam.date, style)}, ${timeOfDay(finalExam.start)}–${timeOfDay(finalExam.end)}`
|
|
53
85
|
: "";
|
|
54
86
|
|
|
55
87
|
/**
|
|
@@ -63,7 +95,6 @@ export const lastMeeting = (lessons) => {
|
|
|
63
95
|
};
|
|
64
96
|
|
|
65
97
|
const SHORT_DATE = { month: "short", day: "numeric" };
|
|
66
|
-
const DUE_DATE = { weekday: "short", month: "short", day: "numeric" };
|
|
67
98
|
|
|
68
99
|
/**
|
|
69
100
|
* Due date for display: "Tue, Oct 27, 11:59PM", or without the time.
|
|
@@ -71,7 +102,7 @@ const DUE_DATE = { weekday: "short", month: "short", day: "numeric" };
|
|
|
71
102
|
* @returns {string}
|
|
72
103
|
*/
|
|
73
104
|
export const dueLabel = (item) =>
|
|
74
|
-
item?.due ? [
|
|
105
|
+
item?.due ? [compactDate(item.due), timeOfDay(item.dueTime)].filter(Boolean).join(", ") : "";
|
|
75
106
|
|
|
76
107
|
/**
|
|
77
108
|
* The kinds of deadline a chip can name, and whether each is graded. The label
|
|
@@ -96,10 +127,10 @@ const kindKey = (kind) => `dueKind${kind.charAt(0).toUpperCase()}${kind.slice(1)
|
|
|
96
127
|
export const dueKindLabel = (kind, copy = COPY_DEFAULTS) => copy.schedule[kindKey(kind)] ?? "";
|
|
97
128
|
|
|
98
129
|
/**
|
|
99
|
-
* The key above the schedule: one entry per kind in use, in a fixed order, with its label and
|
|
130
|
+
* The key above the schedule: one entry per kind in use, in a fixed order, with its label and, for a kind that is not graded, the words that say so.
|
|
100
131
|
* @param {object[]} weeks `scheduleWeeks` output
|
|
101
132
|
* @param {typeof COPY_DEFAULTS} [copy]
|
|
102
|
-
* @returns {{ kind: string, label: string,
|
|
133
|
+
* @returns {{ kind: string, label: string, note: string }[]}
|
|
103
134
|
*/
|
|
104
135
|
export const dueKeyItems = (weeks, copy = COPY_DEFAULTS) => {
|
|
105
136
|
const present = new Set();
|
|
@@ -112,7 +143,7 @@ export const dueKeyItems = (weeks, copy = COPY_DEFAULTS) => {
|
|
|
112
143
|
}
|
|
113
144
|
return Object.entries(DUE_KINDS)
|
|
114
145
|
.filter(([kind]) => present.has(kind))
|
|
115
|
-
.map(([kind, { graded }]) => ({ kind, label: dueKindLabel(kind, copy),
|
|
146
|
+
.map(([kind, { graded }]) => ({ kind, label: dueKindLabel(kind, copy), note: graded ? "" : copy.schedule.notGraded }));
|
|
116
147
|
};
|
|
117
148
|
|
|
118
149
|
/**
|
|
@@ -156,11 +187,11 @@ const weekDates = (meetings) => {
|
|
|
156
187
|
const first = meetings[0]?.date;
|
|
157
188
|
const last = meetings.at(-1)?.date;
|
|
158
189
|
if (!first) return "";
|
|
159
|
-
const start =
|
|
190
|
+
const start = formatDate(first, SHORT_DATE);
|
|
160
191
|
if (!last || last === first) return start;
|
|
161
192
|
return first.slice(0, 7) === last.slice(0, 7)
|
|
162
193
|
? `${start}–${Number(last.slice(8, 10))}`
|
|
163
|
-
: `${start} – ${
|
|
194
|
+
: `${start} – ${formatDate(last, SHORT_DATE)}`;
|
|
164
195
|
};
|
|
165
196
|
|
|
166
197
|
/**
|
|
@@ -230,7 +261,7 @@ export const slideTimetable = (decks, lessons, days = []) => {
|
|
|
230
261
|
return {
|
|
231
262
|
weekday,
|
|
232
263
|
iso: lesson.date,
|
|
233
|
-
date:
|
|
264
|
+
date: formatDate(lesson.date, SHORT_DATE),
|
|
234
265
|
noClass: lesson.noClass,
|
|
235
266
|
deck: deck
|
|
236
267
|
? {
|
|
@@ -282,7 +313,7 @@ export const scheduleWeeks = (lessons, weeks, decks = [], demos = []) => {
|
|
|
282
313
|
meetings: meetings.map((lesson) => ({
|
|
283
314
|
weekday: lesson.weekday,
|
|
284
315
|
iso: lesson.date,
|
|
285
|
-
date:
|
|
316
|
+
date: formatDate(lesson.date, SHORT_DATE),
|
|
286
317
|
display: lesson.display,
|
|
287
318
|
noClass: lesson.noClass,
|
|
288
319
|
substitution: lesson.substitution,
|
|
@@ -384,18 +415,21 @@ export const courseDeadlines = (weeks, schedule, copy = COPY_DEFAULTS) => {
|
|
|
384
415
|
|
|
385
416
|
/**
|
|
386
417
|
* The schedule page's month links: one per calendar month that has a class
|
|
387
|
-
* meeting, in calendar order
|
|
388
|
-
*
|
|
389
|
-
*
|
|
418
|
+
* meeting, in calendar order. `week` is the first week holding a meeting of
|
|
419
|
+
* the month, where the link points, and `last` the last one; a week that
|
|
420
|
+
* spans two months is in both ranges. Dates are ISO strings, so the month is
|
|
421
|
+
* read in UTC and never shifts with the build machine's zone.
|
|
390
422
|
* @param {object[]} weeks `scheduleWeeks` output
|
|
391
|
-
* @returns {{name: string, week: number}[]}
|
|
423
|
+
* @returns {{name: string, week: number, last: number}[]}
|
|
392
424
|
*/
|
|
393
425
|
export const scheduleMonths = (weeks) => {
|
|
394
426
|
const months = new Map();
|
|
395
427
|
for (const { week, meetings } of weeks ?? []) {
|
|
396
428
|
for (const { iso } of meetings.filter((meeting) => !meeting.noClass)) {
|
|
397
429
|
const month = iso.slice(0, 7);
|
|
398
|
-
|
|
430
|
+
const entry = months.get(month);
|
|
431
|
+
if (!entry) months.set(month, { name: formatDate(iso, { month: "long" }), week, last: week });
|
|
432
|
+
else entry.last = Math.max(entry.last, week);
|
|
399
433
|
}
|
|
400
434
|
}
|
|
401
435
|
return [...months.values()];
|
|
@@ -412,9 +446,10 @@ export const scheduleMonths = (weeks) => {
|
|
|
412
446
|
* @param {object} [project] `_data/project.json`
|
|
413
447
|
* @param {object} [finalExam] `schedule.finalExam`
|
|
414
448
|
* @param {typeof COPY_DEFAULTS} [copy] the group titles and labels
|
|
449
|
+
* @param {"full" | "short"} [style] `"short"` writes the project and exam dates in the short form ("Fri, Oct 23, 12:00PM"); the default is the long form
|
|
415
450
|
* @returns {{title: string, items: {label: string, date: string, note?: string}[]}[]}
|
|
416
451
|
*/
|
|
417
|
-
export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAULTS) => {
|
|
452
|
+
export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAULTS, style = "full") => {
|
|
418
453
|
const words = copy.scheduleOverview;
|
|
419
454
|
const meetings = lessons ?? [];
|
|
420
455
|
const tests = meetings.flatMap((lesson) =>
|
|
@@ -424,12 +459,12 @@ export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAUL
|
|
|
424
459
|
);
|
|
425
460
|
const stages = projectMilestones(project).map((milestone) => ({
|
|
426
461
|
label: milestone.label,
|
|
427
|
-
date: [
|
|
462
|
+
date: [dateIn(milestone.due, style), timeOfDay(milestone.dueTime)].filter(Boolean).join(", "),
|
|
428
463
|
}));
|
|
429
464
|
const groups = [
|
|
430
465
|
{ title: words.tests, items: tests },
|
|
431
466
|
{ title: project?.title ?? words.finalProject, items: stages },
|
|
432
|
-
{ title: words.finalExam, items: finalExam ? [{ label: words.exam, date: examSlot(finalExam), note: finalExam.note }] : [] },
|
|
467
|
+
{ title: words.finalExam, items: finalExam ? [{ label: words.exam, date: examSlot(finalExam, style), note: finalExam.note }] : [] },
|
|
433
468
|
{
|
|
434
469
|
title: words.noClass,
|
|
435
470
|
items: meetings.filter((lesson) => lesson.noClass).map((lesson) => ({ label: lesson.noClass, date: lesson.display })),
|
|
@@ -459,7 +494,7 @@ export const demoWeeks = (demos, lessons, decks = []) => {
|
|
|
459
494
|
}
|
|
460
495
|
const dateOf = (ref) => {
|
|
461
496
|
const lesson = (lessons ?? []).find((item) => item.week === ref.week && item.day === ref.day);
|
|
462
|
-
return lesson ?
|
|
497
|
+
return lesson ? formatDate(lesson.date, SHORT_DATE) : "";
|
|
463
498
|
};
|
|
464
499
|
return [...byWeek]
|
|
465
500
|
.map(([week, meetings]) => ({
|
|
@@ -471,7 +506,7 @@ export const demoWeeks = (demos, lessons, decks = []) => {
|
|
|
471
506
|
day: lesson.day,
|
|
472
507
|
weekday: lesson.weekday,
|
|
473
508
|
iso: lesson.date,
|
|
474
|
-
date:
|
|
509
|
+
date: formatDate(lesson.date, SHORT_DATE),
|
|
475
510
|
slides: mainDeck(decks, lesson.week, lesson.day)?.url,
|
|
476
511
|
addendum: addendumFor(decks, lesson.week, lesson.day)?.url,
|
|
477
512
|
demos: (demos ?? [])
|
|
@@ -560,6 +595,8 @@ export const encodeEmail = (email) => (typeof email === "string" && email.includ
|
|
|
560
595
|
/** @param {import('@11ty/eleventy').TemplateConfig} config */
|
|
561
596
|
export default function registerFilters(config) {
|
|
562
597
|
config.addFilter("fullDate", fullDate);
|
|
598
|
+
config.addFilter("compactDate", compactDate);
|
|
599
|
+
config.addFilter("dateIn", dateIn);
|
|
563
600
|
config.addFilter("dateRange", dateRange);
|
|
564
601
|
config.addFilter("examSlot", examSlot);
|
|
565
602
|
config.addFilter("timeOfDay", timeOfDay);
|
package/lib/lesson-materials.js
CHANGED
|
@@ -20,7 +20,7 @@ export const lessonDecks = (data) => decksFor(data.collections?.deck, data.lesso
|
|
|
20
20
|
* The "Materials & links" sections of a lesson-day page, in order, each ready
|
|
21
21
|
* for `<link-section>`. A section with nothing to list is left out, except
|
|
22
22
|
* the resources one, which says so.
|
|
23
|
-
* @param {object} data a lesson-day page's data: `lesson`, `lessons`, `lessonDemos`, `collections`
|
|
23
|
+
* @param {object} data a lesson-day page's data: `lesson`, `lessons`, `lessonDemos` (a list of `{ title, slug, description }`, which a course supplies; anything but a list is no demos), `collections`
|
|
24
24
|
* @returns {{ title: string, items: LinkItem[], empty?: string }[]}
|
|
25
25
|
*/
|
|
26
26
|
export function lessonMaterials(data) {
|
|
@@ -34,7 +34,8 @@ export function lessonMaterials(data) {
|
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
title: copy.demosFromThisMeeting,
|
|
37
|
-
|
|
37
|
+
// Eleventy hands a computed key the string "" while it scans the page's dependencies, so only a list counts.
|
|
38
|
+
items: (Array.isArray(data.lessonDemos) ? data.lessonDemos : []).map((demo) => ({ title: demo.title, href: `/demo/${demo.slug}/`, note: demo.description })),
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
41
|
title: copy.exercisesDue,
|
package/lib/pdf.js
CHANGED
|
@@ -23,6 +23,12 @@ const loadFooterData = ({ course, term, dataDir }) => {
|
|
|
23
23
|
return { course: course ?? data.course, term: term ?? resolveTerm(data) };
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The page margins of the syllabus PDF. `print.css` sets the same margins in its `@page` rule: an @page margin outranks this option, and a
|
|
28
|
+
* smaller one put the text over the page footer, which prints in the bottom margin.
|
|
29
|
+
*/
|
|
30
|
+
export const PDF_MARGIN = { top: "0.4in", bottom: "0.45in", left: "0.5in", right: "0.5in" };
|
|
31
|
+
|
|
26
32
|
const MIME = {
|
|
27
33
|
".css": "text/css",
|
|
28
34
|
".html": "text/html; charset=utf-8",
|
|
@@ -122,7 +128,7 @@ export default function registerSyllabusPdf(config, { isProduction, timezone, ou
|
|
|
122
128
|
displayHeaderFooter: true,
|
|
123
129
|
headerTemplate: "<span></span>",
|
|
124
130
|
footerTemplate: `<div style="width: 100%; font-size: 7px; text-align: center; color: #666;">${fill(resolveCopy({ dataDir }).pdf.footer, { course: footerData.course.code, name: footerData.course.name, term: footerData.term.label, generated, version, page: '<span class="pageNumber"></span>', pages: '<span class="totalPages"></span>' })}</div>`,
|
|
125
|
-
margin:
|
|
131
|
+
margin: PDF_MARGIN,
|
|
126
132
|
});
|
|
127
133
|
await page.close();
|
|
128
134
|
process.stdout.write(`[syllabus-pdf] wrote ${outputPath.replace(root, "")}\n`);
|
package/lib/plugin.js
CHANGED
|
@@ -10,7 +10,7 @@ import { checkOptions, courseWarnings } from "./check.js";
|
|
|
10
10
|
import { buildGlossary, buildLessons, courseDefines, inlineFontFaces, readCourseData, readPackage, resolveAudience, resolvePdf, resolveSite, resolveTerm, withoutSchema } from "./data/index.js";
|
|
11
11
|
import { copyJson, copyReader, fill, plural, resolveCopy } from "./copy.js";
|
|
12
12
|
import registerExtensions from "./extensions.js";
|
|
13
|
-
import registerFilters from "./filters.js";
|
|
13
|
+
import registerFilters, { setDateFormats } from "./filters.js";
|
|
14
14
|
import registerSlideFitCheck from "./fit.js";
|
|
15
15
|
import { registerGlue } from "./glue.js";
|
|
16
16
|
import { markdown } from "./markdown.js";
|
|
@@ -45,6 +45,7 @@ const PYSCRIPT_MINIFIER = {
|
|
|
45
45
|
* @param {{ name?: string, timezone?: string }} [options.institution] the college's name, and the time zone "today" is judged in (default `"UTC"`)
|
|
46
46
|
* @param {{ description?: string, keywords?: string, language?: string }} [options.site] site metadata, derived from the course when omitted
|
|
47
47
|
* @param {{ segments?: object[], defaultDays?: string[] }} [options.lessons] the lesson outline and the meeting days used when the schedule names none
|
|
48
|
+
* @param {{ locale?: string, full?: Intl.DateTimeFormatOptions, short?: Intl.DateTimeFormatOptions }} [options.dateFormats] the language dates are written in (default `"en-US"`), the long form (`fullDate`, default "Monday, August 19, 2026") and the short form (`compactDate`, default "Wed, Aug 19"), each as `Intl.DateTimeFormat` options
|
|
48
49
|
* @param {{ checkMode?: "question" | "end" }} [options.worksheets] site-wide worksheet defaults: `checkMode` is `"end"` (only See results at the end, the default) or `"question"` (also a Check answer button on each question); a worksheet's own `checkMode` wins
|
|
49
50
|
* @param {string[]} [options.components] extra WebC component globs
|
|
50
51
|
* @param {{ runtime?: "none" | "codepen" | "pyscript", dir?: string }} [options.demos] how runnable demos are served
|
|
@@ -59,6 +60,7 @@ export default function courseKit(config, options = {}) {
|
|
|
59
60
|
resolveTheme({ dataDir, theme }); // fail at startup on a bad theme
|
|
60
61
|
resolveCopy({ dataDir, extra: courseCopy }); // and on a bad `strings.json`
|
|
61
62
|
setWorksheetDefaults(worksheets);
|
|
63
|
+
setDateFormats(options.dateFormats);
|
|
62
64
|
const { runtime = "none", dir: demosDir = `${inputDir}/demo` } = demos;
|
|
63
65
|
const { decks: decksDir = `${inputDir}/slides` } = slides;
|
|
64
66
|
|
package/lib/postcss.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
|
|
4
|
+
import advancedPreset from "cssnano-preset-advanced";
|
|
4
5
|
import postcss from "postcss";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -25,8 +26,9 @@ export default function postcssConfig({ env = process.env.ELEVENTY_ENV ?? "devel
|
|
|
25
26
|
stage: 3,
|
|
26
27
|
},
|
|
27
28
|
cssnano: {
|
|
29
|
+
// The preset as an imported function, not its name: cssnano resolves a name against the installed package and warns (CSSNANO_INSTALLED_PRESET) that it is not using its built-in preset.
|
|
28
30
|
preset: [
|
|
29
|
-
|
|
31
|
+
advancedPreset,
|
|
30
32
|
{
|
|
31
33
|
reduceIdents: false,
|
|
32
34
|
// Font families live in custom properties discardUnused cannot see.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allons-y/course-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared layouts, components, styles and build helpers for Eleventy course sites.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "Cassondra Roberts <castastrophe@users.noreply.github.com> (https://allons-y.studio)",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"test": "node --test",
|
|
38
38
|
"schema": "node scripts/theme-schema.js && node scripts/theme-docs.js",
|
|
39
39
|
"docs": "node scripts/component-docs.js && node scripts/copy-docs.js",
|
|
40
|
+
"check:pdf": "node scripts/check-pdf.js",
|
|
40
41
|
"preview": "node scripts/site.js start",
|
|
41
42
|
"preview:build": "node scripts/site.js build",
|
|
42
43
|
"docs:build": "node scripts/site.js build",
|
|
@@ -89,6 +89,11 @@
|
|
|
89
89
|
"default": true,
|
|
90
90
|
"description": "Whether the `<syllabus>` shows its contents list (a row of links above the syllabus, and from 1100px a sticky column beside it). `false` leaves it out. The tag's `contents=\"false\"` attribute does the same for one place and wins over this."
|
|
91
91
|
},
|
|
92
|
+
"navColumns": {
|
|
93
|
+
"enum": ["auto", 1, 2],
|
|
94
|
+
"default": "auto",
|
|
95
|
+
"description": "How many columns the menu in the page header is set in. `auto` (the default) uses two columns when the menu has more than 3 links, which keeps the header short, and one stack otherwise; `1` and `2` fix it either way. The `<masthead>` tag's `nav-columns` attribute does the same for one place and wins over this."
|
|
96
|
+
},
|
|
92
97
|
"textbook": {
|
|
93
98
|
"type": "object",
|
|
94
99
|
"description": "Required text and how to get it — the textbook/materials element Meredith requires. Omit the whole key ONLY when the course has no text: the `<syllabus>` component then renders \"No text is required.\", which is still an explicit materials statement. Never leave the key present but empty.",
|
|
@@ -56,6 +56,26 @@
|
|
|
56
56
|
"pattern": "^/images/",
|
|
57
57
|
"description": "Optional headshot, a site-relative path under /images/ (the file lives in content/assets/images/). Shown on screen beside the instructor details; omitted from print, where the instructor collapses to one line."
|
|
58
58
|
},
|
|
59
|
+
"booking": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Optional one-on-one booking link, shown as a button on its own last line of the instructor panel (in both variants, with the contact links as rows or icons) and wherever a page places `<book-appointment>`. A plain link, so it works without JavaScript and stays clickable in the syllabus PDF. Absent, nothing is shown.",
|
|
62
|
+
"properties": {
|
|
63
|
+
"url": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"format": "uri",
|
|
66
|
+
"description": "Public booking page, such as a Google Calendar appointment schedule or a Calendly link."
|
|
67
|
+
},
|
|
68
|
+
"label": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"minLength": 1,
|
|
71
|
+
"description": "The button's words. Defaults to \"Book an appointment\" (the `instructor.bookAnAppointment` copy key)."
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required": [
|
|
75
|
+
"url"
|
|
76
|
+
],
|
|
77
|
+
"additionalProperties": false
|
|
78
|
+
},
|
|
59
79
|
"note": {
|
|
60
80
|
"type": "string",
|
|
61
81
|
"description": "Response-time expectation, rendered muted after the contact details."
|
|
@@ -26,9 +26,14 @@
|
|
|
26
26
|
"default": true,
|
|
27
27
|
"description": "Set false to keep the page out of the sitemap and search results. Does NOT gate publishing — the page is still served to anyone with the URL."
|
|
28
28
|
},
|
|
29
|
+
"order": {
|
|
30
|
+
"type": "integer",
|
|
31
|
+
"minimum": 0,
|
|
32
|
+
"description": "Where the worksheet sits in the Practice page's list (`<practice-index>`): lower numbers first, then by address. A worksheet with no order comes after those that have one."
|
|
33
|
+
},
|
|
29
34
|
"eyebrow": {
|
|
30
35
|
"type": "string",
|
|
31
|
-
"description": "Small-caps label above the heading,
|
|
36
|
+
"description": "Small-caps label above the heading, such as the kind of page (\"Practice\"). The masthead already gives the term and course code, so the page does not repeat them."
|
|
32
37
|
},
|
|
33
38
|
"heading": {
|
|
34
39
|
"type": "string",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The deck's saved light/dark choice, applied before first paint so a deck
|
|
3
|
-
* never flashes the wrong scheme. Only the deck layout inlines this, through
|
|
4
|
-
* the `head` bundle bucket; the site and worksheets follow the system.
|
|
5
|
-
*/
|
|
6
|
-
try {
|
|
7
|
-
const theme = localStorage.getItem("theme");
|
|
8
|
-
if (theme === "light" || theme === "dark") {
|
|
9
|
-
document.documentElement.style.colorScheme = theme;
|
|
10
|
-
document.documentElement.dataset.theme = theme;
|
|
11
|
-
for (const link of document.querySelectorAll("link[data-prism-theme]")) {
|
|
12
|
-
link.media = link.dataset.prismTheme === theme ? "all" : "not all";
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
} catch {
|
|
16
|
-
// Storage can be unavailable (private mode, blocked cookies); follow system.
|
|
17
|
-
}
|