@allons-y/course-kit 0.3.0 → 0.4.1

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.
@@ -985,7 +985,8 @@ eyebrow + :where(h1, h2, h3, h4, h5, h6) {
985
985
  A contents column beside a document (and beside the syllabus, whose own
986
986
  component sets where it sits), and an outline and a tools rail beside
987
987
  a lesson plan. Only the syllabus's list is sticky, and each falls to one
988
- column on a narrow screen, the side columns first. */
988
+ column on a narrow screen: a document's contents go after the page, the
989
+ lesson plan's side columns first. */
989
990
  .rail-label {
990
991
  margin: 0 0 0.5em;
991
992
  color: var(--color-text-muted);
@@ -1013,14 +1014,19 @@ body:has(.doc-layout[data-contents="true"], .lesson-layout) {
1013
1014
 
1014
1015
  .doc-layout[data-contents="true"] {
1015
1016
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
1016
- /* The page is first in the source; the grid puts the contents beside it, or above it on a narrow screen. */
1017
+ /* The page is first in the source; the grid puts the contents beside it, or after it on a narrow screen, so the h1 is the first thing on a phone and the visual order is the reading order. */
1017
1018
  grid-template-areas: "contents page";
1018
1019
 
1019
1020
  @media screen and (width <= 900px) {
1020
1021
  grid-template-columns: minmax(0, 1fr);
1021
1022
  grid-template-areas:
1022
- "contents"
1023
- "page";
1023
+ "page"
1024
+ "contents";
1025
+
1026
+ > .doc-contents {
1027
+ margin-block-start: var(--section-space);
1028
+ border-block-start: var(--thin-border-width) solid var(--color-border);
1029
+ }
1024
1030
  }
1025
1031
 
1026
1032
  @media print {
@@ -1179,6 +1185,23 @@ body:has(.doc-layout[data-contents="true"], .lesson-layout) {
1179
1185
  }
1180
1186
  }
1181
1187
 
1188
+ /* `.separators` sets `display: flex` after the utility classes above and outranks them, so a row that is for one medium only needs its own rules. */
1189
+ .separators.print-only {
1190
+ display: none;
1191
+ }
1192
+
1193
+ .separators.screen-only {
1194
+ @media print {
1195
+ display: none;
1196
+ }
1197
+ }
1198
+
1199
+ .separators.print-only {
1200
+ @media print {
1201
+ display: flex;
1202
+ }
1203
+ }
1204
+
1182
1205
  .lesson-list {
1183
1206
  td {
1184
1207
  font-size: max(var(--base-font-size), 0.95em);
@@ -1250,8 +1273,8 @@ body:has(.doc-layout[data-contents="true"], .lesson-layout) {
1250
1273
  border-inline: none;
1251
1274
  }
1252
1275
 
1253
- /* A link that is the whole cell is an operable target: 44px tall (WCAG 2.5.5); print sets --target-min to 0. */
1254
- :where(td, th) > a:only-child {
1276
+ /* A link that is a direct child of a cell is an operable target: 44px tall (WCAG 2.5.5); print sets --target-min to 0. */
1277
+ :where(td, th) > a {
1255
1278
  display: inline-flex;
1256
1279
  align-items: center;
1257
1280
  min-block-size: var(--target-min);
@@ -1953,6 +1976,63 @@ blockquote {
1953
1976
  color: var(--color-text-muted);
1954
1977
  }
1955
1978
 
1979
+ /* ---- The call-to-action button ----
1980
+ One primary action as a link: the accent pill, 44px tall, in the brand fill under its own text color (7:1). It needs its words, so it
1981
+ is never an icon. `a.cta-button[href]` outranks the prose link rules above, which underline and recolor a link inside a paragraph or
1982
+ list item and on hover. Motion only where the reader has not asked for less; print shows a plain underlined link. */
1983
+ a.cta-button[href] {
1984
+ display: inline-flex;
1985
+ align-items: center;
1986
+ justify-content: center;
1987
+ box-sizing: border-box;
1988
+ min-block-size: var(--target-min);
1989
+ min-inline-size: var(--target-min);
1990
+ padding: 0.6em 1.4em;
1991
+ border: var(--border-width) solid var(--color-accent);
1992
+ border-radius: var(--radius-pill);
1993
+ background-color: var(--color-accent);
1994
+ color: var(--color-on-accent);
1995
+ font-weight: var(--font-weight--semi-bold);
1996
+ line-height: var(--font-height);
1997
+ text-align: center;
1998
+ text-decoration: none;
1999
+
2000
+ @media (prefers-reduced-motion: no-preference) {
2001
+ transition:
2002
+ background-color 150ms ease-out,
2003
+ border-color 150ms ease-out;
2004
+ }
2005
+
2006
+ &:is(:hover, :focus, :focus-visible) {
2007
+ background-color: var(--color-accent-fill-hover);
2008
+ border-color: var(--color-accent-fill-hover);
2009
+ color: var(--color-on-accent);
2010
+ text-decoration: none;
2011
+ }
2012
+
2013
+ /* A forced palette drops the fill, so the pill is its outline and its text. */
2014
+ @media (forced-colors: active) {
2015
+ border-color: LinkText;
2016
+ color: LinkText;
2017
+
2018
+ &:is(:hover, :focus, :focus-visible) {
2019
+ border-color: Highlight;
2020
+ color: LinkText;
2021
+ }
2022
+ }
2023
+
2024
+ @media print {
2025
+ display: inline;
2026
+ min-block-size: 0;
2027
+ min-inline-size: 0;
2028
+ padding: 0;
2029
+ border: 0;
2030
+ background: none;
2031
+ color: inherit;
2032
+ text-decoration: underline;
2033
+ }
2034
+ }
2035
+
1956
2036
  /* ---- The switch ----
1957
2037
  One pill track holding two to four options: native radios for a choice that
1958
2038
  filters (Group by), tabs for one that swaps a panel (Review / Flashcards).
@@ -0,0 +1,26 @@
1
+ <script webc:setup>
2
+ /**
3
+ * The one-on-one booking button: a link to `instructor.booking.url`, labelled by `instructor.booking.label` or the `instructor.bookAnAppointment` copy key. Renders nothing when the instructor has no `booking`. `<instructor>` places it as the last line of the panel; a page, such as the contact page, can place it anywhere.
4
+ */
5
+ </script>
6
+ <div webc:root="override" class="book-appointment" webc:if="$data.instructor?.booking?.url">
7
+ <a class="cta-button" :href="$data.instructor.booking.url" @text="$data.instructor.booking.label || $data.copy.instructor.bookAnAppointment"></a>
8
+ </div>
9
+
10
+ <style webc:scoped>
11
+ /* Aligned with the content's start edge, with space above it. In the instructor panel with icon links on, the column is a wrapping
12
+ flex row (the kit orders heading 0, icons 1, facts 2, note 3), and the button takes its own line last; anywhere else the two
13
+ flex properties do nothing. The pill itself is `.cta-button` in the base stylesheet. */
14
+ :host {
15
+ display: flex;
16
+ justify-content: flex-start;
17
+ flex: 1 1 100%;
18
+ order: 4;
19
+ margin-block-start: var(--content-space);
20
+
21
+ @media print {
22
+ display: block;
23
+ margin-block-start: 0.4em;
24
+ }
25
+ }
26
+ </style>
@@ -1,6 +1,6 @@
1
1
  <script webc:setup>
2
2
  /**
3
- * The instructor's details: photo, office, contact and hours. Reads `instructor`.
3
+ * The instructor's details: photo, office, contact and hours, then the booking button (`instructor.booking`) as the panel's last line when there is one. Reads `instructor`.
4
4
  * @prop {'card'} [variant] a compact card instead of the full section
5
5
  * @prop {'icons'} [contactLinks] show the email, the message link and the blog as icon links in the corner of the panel instead of rows in the fact list; the same as `contactLinks: "icons"` in `instructor.json`, and wins over it
6
6
  */
@@ -61,7 +61,7 @@
61
61
  aria-hidden="true" focusable="false" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"></circle><path d="M3 12h18"></path><path d="M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18"></path></svg><span
62
62
  class="link-text" @text="host($data.instructor.blog)"></span></a>
63
63
  </li>
64
- </ul>
64
+ </ul><book-appointment></book-appointment>
65
65
  </div>
66
66
  </div>
67
67
  </template>
@@ -84,7 +84,7 @@
84
84
  <a webc:if="$data.instructor.email" :data-email="encodeEmail($data.instructor.email)" :class="$data.instructor.contact ? 'print-only' : ''"></a>
85
85
  <a webc:if="$data.instructor.blog" class="cta" :href="$data.instructor.blog" @text="$data.instructor.blog.replace(/^https?:\/\//, '').replace(/\/$/, '')"></a>
86
86
  </p>
87
- <p class="muted note" @text="$data.instructor.note" webc:if="$data.instructor.note"></p>
87
+ <p class="muted note" @text="$data.instructor.note" webc:if="$data.instructor.note"></p><book-appointment></book-appointment>
88
88
  </div>
89
89
  </div>
90
90
  </template>
@@ -10,8 +10,14 @@
10
10
  * output; built from the page's lessons, project and exam slot when left out
11
11
  * @prop {object[]} [weeks] `scheduleWeeks` output, for the month links;
12
12
  * built from the page when left out
13
+ * @prop {'short' | 'full'} [dateStyle] how the key dates write a project
14
+ * milestone's and the final exam's date: `full` (the default, "Friday,
15
+ * October 23, 2026, 12:00PM") or `short` ("Fri, Oct 23, 12:00PM"). Written
16
+ * `@date-style`
13
17
  */
14
18
  const defaultGroups = scheduleKeyDates($data.lessons, $data.project, $data.schedule?.finalExam, $data.copy);
19
+ /** The key dates for a date style; the setup script cannot see props, so the template calls this with its own. */
20
+ const groupsFor = (style) => (style === "short" ? scheduleKeyDates($data.lessons, $data.project, $data.schedule?.finalExam, $data.copy, "short") : defaultGroups);
15
21
  const defaultWeeks = scheduleWeeks($data.lessons, $data.schedule?.weeks, $data.collections?.deck, $data.demos);
16
22
  </script>
17
23
  <header webc:root="override" class="schedule-overview">
@@ -23,9 +29,9 @@
23
29
  <span webc:if="$data.instructor?.office" @text="$data.instructor.office"></span>
24
30
  </p>
25
31
 
26
- <section class="key-dates" aria-labelledby="schedule-key-dates" webc:if="(groups ?? defaultGroups)?.length">
32
+ <section class="key-dates" aria-labelledby="schedule-key-dates" webc:if="(groups ?? groupsFor(typeof dateStyle === 'undefined' ? undefined : dateStyle))?.length">
27
33
  <h2 id="schedule-key-dates" @text="$data.copy.scheduleOverview.keyDates"></h2>
28
- <div class="group" webc:for="group of (groups ?? defaultGroups)">
34
+ <div class="group" webc:for="group of (groups ?? groupsFor(typeof dateStyle === 'undefined' ? undefined : dateStyle))">
29
35
  <h3 @text="group.title"></h3>
30
36
  <ul role="list">
31
37
  <li webc:for="item of group.items">
@@ -112,6 +112,15 @@
112
112
  margin-block-start: 0.25em;
113
113
  }
114
114
 
115
+ /* Each link is a 44px target (WCAG 2.5.5); it sits in a paragraph, so the
116
+ table-wide cell-link rule does not reach it. */
117
+ :host :is(.deck-title, .notes) a {
118
+ display: inline-flex;
119
+ align-items: center;
120
+ gap: 0.25em;
121
+ min-block-size: var(--target-min);
122
+ }
123
+
115
124
  @media screen and (width <= 640px) {
116
125
  :host,
117
126
  :host tbody,
@@ -5,6 +5,7 @@
5
5
  * @prop {string[]} [levels] level names across the top
6
6
  * @prop {string} [caption] a screen-reader caption
7
7
  * @prop {number} [total] the points the rubric adds up to, shown in the footer
8
+ * @prop {'short' | 'full'} [dateStyle] how a milestone's due date is written in the narrow Due column: `short` (the default, "Fri, Oct 23, 12:00PM") or `full` ("Friday, October 23, 2026, 12:00PM"). Written `@date-style`
8
9
  * @prop {Record<string, string>} copy the table's wording: `copy.tableRubric` (`criteria`, `points`, `pointsEach`, `totalPointsPossible`, `milestone`, `due`, `whatIsGraded`)
9
10
  */
10
11
  </script>
@@ -47,7 +48,7 @@
47
48
  <span class="id" webc:if="criterion.id" @text="criterion.id"></span>
48
49
  <span @text="criterion.title"></span>
49
50
  </th>
50
- <td role="cell" class="due"><span class="cell-label" aria-hidden="true" @text="copy.due"></span><span @text="criterion.due ? fullDate(criterion.due) + (criterion.dueTime ? `, ${criterion.dueTime}` : '') : ''"></span></td>
51
+ <td role="cell" class="due"><span class="cell-label" aria-hidden="true" @text="copy.due"></span><span @text="criterion.due ? dateIn(criterion.due, typeof dateStyle === 'undefined' ? 'short' : dateStyle) + (criterion.dueTime ? `, ${timeOfDay(criterion.dueTime)}` : '') : ''"></span></td>
51
52
  <td role="cell" class="num"><span class="cell-label" aria-hidden="true" @text="copy.points"></span><span @text="criterion.points"></span></td>
52
53
  <td role="cell"><span class="cell-label" aria-hidden="true" @text="copy.whatIsGraded"></span><span @text="criterion.description"></span></td>
53
54
  </tr>
@@ -2,7 +2,7 @@
2
2
  layout: "base"
3
3
  ---
4
4
  <div class="doc-layout" :data-contents="toc(content) ? 'true' : 'false'">
5
- <!-- The page comes first in the source, so its h1 is the first thing a screen reader reaches; the contents rail is placed beside or above it by the grid. -->
5
+ <!-- The page comes first in the source, so its h1 is the first thing a screen reader reaches; the contents rail is placed beside it, or after it on a phone, by the grid. -->
6
6
  <article class="content-column" @raw="content"></article>
7
7
  <div class="doc-contents" webc:if="toc(content)">
8
8
  <p class="rail-label" id="doc-contents-label" @text="$data.copy.document.contents"></p>
package/lib/check.js CHANGED
@@ -15,6 +15,7 @@ const OPTIONS = {
15
15
  pdf: ["course", "term", "dataDir"],
16
16
  prism: ["theme", "plugins"],
17
17
  worksheets: ["checkMode"],
18
+ dateFormats: ["locale", "full", "short"],
18
19
  };
19
20
 
20
21
  const RUNTIMES = ["none", "codepen", "pyscript"];
@@ -85,6 +86,23 @@ export function checkOptions(options = {}) {
85
86
  if (checkMode !== undefined && !["question", "end"].includes(checkMode)) {
86
87
  throw new Error(`courseKit: \`worksheets.checkMode\` is "${checkMode}", but it must be "question" or "end".`);
87
88
  }
89
+ const { locale, full, short } = options.dateFormats ?? {};
90
+ if (locale !== undefined) {
91
+ try {
92
+ new Intl.DateTimeFormat(locale);
93
+ } catch {
94
+ throw new Error(`courseKit: \`dateFormats.locale\` is ${JSON.stringify(locale)}, which is not a language tag. Use one like "en-US" or "fr-CA".`);
95
+ }
96
+ }
97
+ for (const [name, format] of [["full", full], ["short", short]]) {
98
+ if (format === undefined) continue;
99
+ try {
100
+ if (format === null || typeof format !== "object" || Array.isArray(format)) throw new TypeError("not an object");
101
+ new Intl.DateTimeFormat(locale ?? "en-US", { timeZone: "UTC", ...format });
102
+ } catch {
103
+ throw new Error(`courseKit: \`dateFormats.${name}\` must be Intl.DateTimeFormat options, such as { weekday: "short", month: "short", day: "numeric" }.`);
104
+ }
105
+ }
88
106
  if (options.components !== undefined && !Array.isArray(options.components)) {
89
107
  throw new Error("courseKit: `components` must be a list of file patterns, such as [\"components/*.webc\"].");
90
108
  }
package/lib/copy.js CHANGED
@@ -334,6 +334,7 @@ export const COPY_DEFAULTS = {
334
334
  instructor: "Instructor",
335
335
  contact: "Contact",
336
336
  blogUrl: "Blog: {url}",
337
+ bookAnAppointment: "Book an appointment",
337
338
  },
338
339
  codepenEmbed: {
339
340
  theCode: "The code",
@@ -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: dateFormat(meeting.date, MONTH_DAY),
223
+ when: formatDate(meeting.date, MONTH_DAY),
225
224
  deck: title,
226
225
  });
227
226
 
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
- /** "Monday, August 19, 2026" */
15
- export const fullDate = (iso) => dateFormat(iso, FULL);
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
- ? `${dateFormat(start, MONTH_DAY)}–${Number(end.slice(8, 10))}, ${end.slice(0, 4)}`
24
- : `${dateFormat(start, MONTH_DAY)} – ${dateFormat(end, MONTH_DAY)}, ${end.slice(0, 4)}`;
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:00am–12:00pm".
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
- ? `${fullDate(finalExam.date)}, ${timeOfDay(finalExam.start)}–${timeOfDay(finalExam.end)}`
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 ? [dateFormat(item.due, DUE_DATE), timeOfDay(item.dueTime)].filter(Boolean).join(", ") : "";
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
@@ -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 = dateFormat(first, SHORT_DATE);
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} – ${dateFormat(last, SHORT_DATE)}`;
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: dateFormat(lesson.date, SHORT_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: dateFormat(lesson.date, SHORT_DATE),
316
+ date: formatDate(lesson.date, SHORT_DATE),
286
317
  display: lesson.display,
287
318
  noClass: lesson.noClass,
288
319
  substitution: lesson.substitution,
@@ -397,7 +428,7 @@ export const scheduleMonths = (weeks) => {
397
428
  for (const { iso } of meetings.filter((meeting) => !meeting.noClass)) {
398
429
  const month = iso.slice(0, 7);
399
430
  const entry = months.get(month);
400
- if (!entry) months.set(month, { name: dateFormat(iso, { month: "long" }), week, last: week });
431
+ if (!entry) months.set(month, { name: formatDate(iso, { month: "long" }), week, last: week });
401
432
  else entry.last = Math.max(entry.last, week);
402
433
  }
403
434
  }
@@ -415,9 +446,10 @@ export const scheduleMonths = (weeks) => {
415
446
  * @param {object} [project] `_data/project.json`
416
447
  * @param {object} [finalExam] `schedule.finalExam`
417
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
418
450
  * @returns {{title: string, items: {label: string, date: string, note?: string}[]}[]}
419
451
  */
420
- export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAULTS) => {
452
+ export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAULTS, style = "full") => {
421
453
  const words = copy.scheduleOverview;
422
454
  const meetings = lessons ?? [];
423
455
  const tests = meetings.flatMap((lesson) =>
@@ -427,12 +459,12 @@ export const scheduleKeyDates = (lessons, project, finalExam, copy = COPY_DEFAUL
427
459
  );
428
460
  const stages = projectMilestones(project).map((milestone) => ({
429
461
  label: milestone.label,
430
- date: [fullDate(milestone.due), timeOfDay(milestone.dueTime)].filter(Boolean).join(", "),
462
+ date: [dateIn(milestone.due, style), timeOfDay(milestone.dueTime)].filter(Boolean).join(", "),
431
463
  }));
432
464
  const groups = [
433
465
  { title: words.tests, items: tests },
434
466
  { title: project?.title ?? words.finalProject, items: stages },
435
- { 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 }] : [] },
436
468
  {
437
469
  title: words.noClass,
438
470
  items: meetings.filter((lesson) => lesson.noClass).map((lesson) => ({ label: lesson.noClass, date: lesson.display })),
@@ -462,7 +494,7 @@ export const demoWeeks = (demos, lessons, decks = []) => {
462
494
  }
463
495
  const dateOf = (ref) => {
464
496
  const lesson = (lessons ?? []).find((item) => item.week === ref.week && item.day === ref.day);
465
- return lesson ? dateFormat(lesson.date, SHORT_DATE) : "";
497
+ return lesson ? formatDate(lesson.date, SHORT_DATE) : "";
466
498
  };
467
499
  return [...byWeek]
468
500
  .map(([week, meetings]) => ({
@@ -474,7 +506,7 @@ export const demoWeeks = (demos, lessons, decks = []) => {
474
506
  day: lesson.day,
475
507
  weekday: lesson.weekday,
476
508
  iso: lesson.date,
477
- date: dateFormat(lesson.date, SHORT_DATE),
509
+ date: formatDate(lesson.date, SHORT_DATE),
478
510
  slides: mainDeck(decks, lesson.week, lesson.day)?.url,
479
511
  addendum: addendumFor(decks, lesson.week, lesson.day)?.url,
480
512
  demos: (demos ?? [])
@@ -563,6 +595,8 @@ export const encodeEmail = (email) => (typeof email === "string" && email.includ
563
595
  /** @param {import('@11ty/eleventy').TemplateConfig} config */
564
596
  export default function registerFilters(config) {
565
597
  config.addFilter("fullDate", fullDate);
598
+ config.addFilter("compactDate", compactDate);
599
+ config.addFilter("dateIn", dateIn);
566
600
  config.addFilter("dateRange", dateRange);
567
601
  config.addFilter("examSlot", examSlot);
568
602
  config.addFilter("timeOfDay", timeOfDay);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allons-y/course-kit",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
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)",
@@ -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."