@backgold/template-kit 0.0.0-stage → 0.1.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.
Files changed (340) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/chunk-KOB36GSF.js +62 -0
  4. package/dist/constants-DvTNj4JI.d-Batjcj3Z.d.ts +38 -0
  5. package/dist/content-api-CYeY0vU8.d.ts +849 -0
  6. package/dist/contract/content-api-examples.d.ts +58 -0
  7. package/dist/contract/content-api-examples.js +783 -0
  8. package/dist/contract/content-api.d.ts +2 -0
  9. package/dist/contract/content-api.js +1 -0
  10. package/dist/contract/site-templates.d.ts +252 -0
  11. package/dist/contract/site-templates.js +185 -0
  12. package/package.json +70 -3
  13. package/src/components/EntryCard.astro +35 -0
  14. package/src/components/EventMap.astro +118 -0
  15. package/src/components/EventPage.astro +194 -0
  16. package/src/components/FieldValue.astro +41 -0
  17. package/src/components/LeadingHero.astro +21 -0
  18. package/src/components/NotFound.astro +20 -0
  19. package/src/components/PageSections.astro +47 -0
  20. package/src/components/Prose.astro +18 -0
  21. package/src/components/chrome/Brand.astro +54 -0
  22. package/src/components/chrome/ClosingCall.astro +94 -0
  23. package/src/components/chrome/DonateStrip.astro +61 -0
  24. package/src/components/chrome/FooterColumns.astro +32 -0
  25. package/src/components/chrome/FooterContact.astro +28 -0
  26. package/src/components/chrome/MenuList.astro +45 -0
  27. package/src/components/chrome/ModeToggle.astro +125 -0
  28. package/src/components/chrome/SignedInNotice.astro +53 -0
  29. package/src/components/chrome/SignupBand.astro +12 -0
  30. package/src/components/chrome/TakeoverBanner.astro +56 -0
  31. package/src/components/chrome/VisitorAccount.astro +82 -0
  32. package/src/components/entries/AuthorBox.astro +47 -0
  33. package/src/components/entries/EntryFields.astro +29 -0
  34. package/src/components/entries/EntryHeader.astro +77 -0
  35. package/src/components/entries/ListFrame.astro +126 -0
  36. package/src/components/entries/ListSearch.astro +24 -0
  37. package/src/components/entries/Share.astro +24 -0
  38. package/src/components/entries/course/classroom.astro +26 -0
  39. package/src/components/entries/course/lesson.astro +18 -0
  40. package/src/components/entries/course/section.ts +20 -0
  41. package/src/components/entries/course/syllabus.astro +15 -0
  42. package/src/components/entries/index.ts +77 -0
  43. package/src/components/entries/newsletter/issue.astro +41 -0
  44. package/src/components/entries/newsletter/list.astro +26 -0
  45. package/src/components/entries/podcast/episode.astro +42 -0
  46. package/src/components/entries/podcast/list.astro +36 -0
  47. package/src/components/entries/post/article.astro +31 -0
  48. package/src/components/entries/post/list.astro +85 -0
  49. package/src/components/entries/props.ts +61 -0
  50. package/src/components/entries/video/cards.astro +39 -0
  51. package/src/components/entries/video/grid.astro +15 -0
  52. package/src/components/entries/video/watch.astro +41 -0
  53. package/src/components/live/LivePage.astro +215 -0
  54. package/src/components/live/LocalTime.astro +29 -0
  55. package/src/components/sections/About/books.astro +188 -0
  56. package/src/components/sections/About/credentials.ts +90 -0
  57. package/src/components/sections/About/index.astro +57 -0
  58. package/src/components/sections/About/left.astro +54 -0
  59. package/src/components/sections/About/letter.astro +108 -0
  60. package/src/components/sections/About/portrait.astro +308 -0
  61. package/src/components/sections/Advocacy/compact.astro +14 -0
  62. package/src/components/sections/Advocacy/index.astro +14 -0
  63. package/src/components/sections/Band.astro +39 -0
  64. package/src/components/sections/Blog/feature.astro +176 -0
  65. package/src/components/sections/Blog/index.astro +37 -0
  66. package/src/components/sections/Blog/latest.ts +80 -0
  67. package/src/components/sections/Blog/list.astro +186 -0
  68. package/src/components/sections/Booking/index.astro +139 -0
  69. package/src/components/sections/Booking/list.astro +144 -0
  70. package/src/components/sections/Booking/types.ts +60 -0
  71. package/src/components/sections/Calendar/agenda.astro +14 -0
  72. package/src/components/sections/Calendar/index.astro +14 -0
  73. package/src/components/sections/CandidateRoster/ballot.astro +394 -0
  74. package/src/components/sections/CandidateRoster/candidates.ts +69 -0
  75. package/src/components/sections/CandidateRoster/compact.astro +115 -0
  76. package/src/components/sections/CandidateRoster/index.astro +57 -0
  77. package/src/components/sections/CaseStudies/beforeafter.astro +222 -0
  78. package/src/components/sections/CaseStudies/cases.ts +111 -0
  79. package/src/components/sections/CaseStudies/grid.astro +261 -0
  80. package/src/components/sections/CaseStudies/index.astro +333 -0
  81. package/src/components/sections/Classroom/CourseCard.astro +181 -0
  82. package/src/components/sections/Classroom/Courses.astro +88 -0
  83. package/src/components/sections/Classroom/classroom.ts +141 -0
  84. package/src/components/sections/Classroom/index.astro +20 -0
  85. package/src/components/sections/Classroom/list.astro +15 -0
  86. package/src/components/sections/Collection/compact.astro +7 -0
  87. package/src/components/sections/Collection/entries.ts +62 -0
  88. package/src/components/sections/Collection/feature.astro +180 -0
  89. package/src/components/sections/Collection/index.astro +46 -0
  90. package/src/components/sections/Collection/library.astro +271 -0
  91. package/src/components/sections/Collection/list.astro +7 -0
  92. package/src/components/sections/Collection/outline.astro +134 -0
  93. package/src/components/sections/Collection/shelves.astro +191 -0
  94. package/src/components/sections/Comparison/Unlisted.astro +6 -0
  95. package/src/components/sections/Comparison/cards.astro +171 -0
  96. package/src/components/sections/Comparison/index.astro +191 -0
  97. package/src/components/sections/Comparison/sides.ts +98 -0
  98. package/src/components/sections/Comparison/spectrum.astro +261 -0
  99. package/src/components/sections/ContentPost/banner.astro +152 -0
  100. package/src/components/sections/ContentPost/index.astro +35 -0
  101. package/src/components/sections/ContentPost/lesson.ts +119 -0
  102. package/src/components/sections/ContentPost/player.astro +254 -0
  103. package/src/components/sections/ContentPost/theater.astro +329 -0
  104. package/src/components/sections/Countdown/index.astro +53 -0
  105. package/src/components/sections/Course/Bar.astro +46 -0
  106. package/src/components/sections/Course/CourseHead.astro +123 -0
  107. package/src/components/sections/Course/Crumbs.astro +44 -0
  108. package/src/components/sections/Course/Icon.astro +29 -0
  109. package/src/components/sections/Course/Ring.astro +62 -0
  110. package/src/components/sections/Course/Syllabus.astro +146 -0
  111. package/src/components/sections/Course/course.ts +146 -0
  112. package/src/components/sections/Course/index.astro +143 -0
  113. package/src/components/sections/Course/outline.astro +39 -0
  114. package/src/components/sections/Cta/banner.astro +64 -0
  115. package/src/components/sections/Cta/card.astro +88 -0
  116. package/src/components/sections/Cta/index.astro +31 -0
  117. package/src/components/sections/Cta/photo.astro +114 -0
  118. package/src/components/sections/Cta/strip.astro +91 -0
  119. package/src/components/sections/Donate/index.astro +136 -0
  120. package/src/components/sections/Donate/story.astro +7 -0
  121. package/src/components/sections/Event/card.astro +14 -0
  122. package/src/components/sections/Event/index.astro +14 -0
  123. package/src/components/sections/EventsList/AgendaMonths.astro +105 -0
  124. package/src/components/sections/EventsList/CalendarLine.astro +23 -0
  125. package/src/components/sections/EventsList/EventRows.astro +196 -0
  126. package/src/components/sections/EventsList/LiveCounts.astro +75 -0
  127. package/src/components/sections/EventsList/TypeTabs.astro +53 -0
  128. package/src/components/sections/EventsList/agenda.astro +55 -0
  129. package/src/components/sections/EventsList/calendar.astro +392 -0
  130. package/src/components/sections/EventsList/cards.astro +186 -0
  131. package/src/components/sections/EventsList/cohorts.astro +205 -0
  132. package/src/components/sections/EventsList/compact.astro +163 -0
  133. package/src/components/sections/EventsList/events.ts +168 -0
  134. package/src/components/sections/EventsList/index.astro +46 -0
  135. package/src/components/sections/EventsList/map.astro +436 -0
  136. package/src/components/sections/EventsList/shifts.astro +355 -0
  137. package/src/components/sections/EventsList/week.astro +361 -0
  138. package/src/components/sections/Faq/Contact.astro +63 -0
  139. package/src/components/sections/Faq/Questions.astro +98 -0
  140. package/src/components/sections/Faq/cards.astro +74 -0
  141. package/src/components/sections/Faq/faq.ts +101 -0
  142. package/src/components/sections/Faq/index.astro +49 -0
  143. package/src/components/sections/Faq/topics.astro +178 -0
  144. package/src/components/sections/Financials/Foot.astro +38 -0
  145. package/src/components/sections/Financials/Head.astro +47 -0
  146. package/src/components/sections/Financials/donut.astro +197 -0
  147. package/src/components/sections/Financials/financials.ts +52 -0
  148. package/src/components/sections/Financials/index.astro +148 -0
  149. package/src/components/sections/Financials/table.astro +157 -0
  150. package/src/components/sections/FormBlock/index.astro +33 -0
  151. package/src/components/sections/FormBlock/wide.astro +7 -0
  152. package/src/components/sections/Hero/cover.astro +170 -0
  153. package/src/components/sections/Hero/donate.astro +209 -0
  154. package/src/components/sections/Hero/field.astro +390 -0
  155. package/src/components/sections/Hero/index.astro +52 -0
  156. package/src/components/sections/Hero/overlap.astro +151 -0
  157. package/src/components/sections/Hero/rotating.astro +30 -0
  158. package/src/components/sections/Hero/split.astro +96 -0
  159. package/src/components/sections/Hero/statement.astro +55 -0
  160. package/src/components/sections/Hero/video.astro +399 -0
  161. package/src/components/sections/Issues/checklist.astro +204 -0
  162. package/src/components/sections/Issues/drawer.astro +237 -0
  163. package/src/components/sections/Issues/index.astro +115 -0
  164. package/src/components/sections/Issues/issues.ts +37 -0
  165. package/src/components/sections/Issues/numbered.astro +79 -0
  166. package/src/components/sections/Issues/rows.astro +137 -0
  167. package/src/components/sections/Issues/steps.astro +81 -0
  168. package/src/components/sections/Issues/tabs.astro +322 -0
  169. package/src/components/sections/Leaderboard/index.astro +29 -0
  170. package/src/components/sections/Lesson/Door.astro +121 -0
  171. package/src/components/sections/Lesson/LessonBody.astro +416 -0
  172. package/src/components/sections/Lesson/Rail.astro +182 -0
  173. package/src/components/sections/Lesson/Tracker.astro +137 -0
  174. package/src/components/sections/Lesson/index.astro +27 -0
  175. package/src/components/sections/Lesson/lesson.ts +233 -0
  176. package/src/components/sections/Lesson/reading.astro +21 -0
  177. package/src/components/sections/Map/CoverageLine.astro +19 -0
  178. package/src/components/sections/Map/RegionMap.astro +109 -0
  179. package/src/components/sections/Map/bar.astro +160 -0
  180. package/src/components/sections/Map/index.astro +192 -0
  181. package/src/components/sections/Map/map.astro +275 -0
  182. package/src/components/sections/MediaKit/BioCard.astro +108 -0
  183. package/src/components/sections/MediaKit/Downloads.astro +88 -0
  184. package/src/components/sections/MediaKit/index.astro +183 -0
  185. package/src/components/sections/MediaKit/kit.ts +140 -0
  186. package/src/components/sections/MediaKit/press.astro +189 -0
  187. package/src/components/sections/MediaKit/speaker.astro +205 -0
  188. package/src/components/sections/Membership/Benefits.astro +42 -0
  189. package/src/components/sections/Membership/Check.astro +12 -0
  190. package/src/components/sections/Membership/Price.astro +61 -0
  191. package/src/components/sections/Membership/compare.astro +312 -0
  192. package/src/components/sections/Membership/index.astro +281 -0
  193. package/src/components/sections/Membership/offers.ts +169 -0
  194. package/src/components/sections/Membership/tiers.astro +217 -0
  195. package/src/components/sections/MovementMap/index.astro +50 -0
  196. package/src/components/sections/MovementTicker/index.astro +43 -0
  197. package/src/components/sections/Pathways/Doors.astro +147 -0
  198. package/src/components/sections/Pathways/Head.astro +37 -0
  199. package/src/components/sections/Pathways/index.astro +27 -0
  200. package/src/components/sections/Pathways/pathways.ts +100 -0
  201. package/src/components/sections/Pathways/quiz.astro +286 -0
  202. package/src/components/sections/Pathways/tabs.astro +271 -0
  203. package/src/components/sections/PdfEmbed/card.astro +99 -0
  204. package/src/components/sections/PdfEmbed/index.astro +26 -0
  205. package/src/components/sections/PdfEmbed/medium.astro +7 -0
  206. package/src/components/sections/PdfEmbed/tall.astro +7 -0
  207. package/src/components/sections/Petition/coverage.astro +14 -0
  208. package/src/components/sections/Petition/image.astro +14 -0
  209. package/src/components/sections/Petition/index.astro +14 -0
  210. package/src/components/sections/Petition/map.astro +14 -0
  211. package/src/components/sections/PlatformPlanks/anchors.ts +66 -0
  212. package/src/components/sections/PlatformPlanks/columns.astro +171 -0
  213. package/src/components/sections/PlatformPlanks/index.astro +56 -0
  214. package/src/components/sections/PlatformPlanks/longread.astro +250 -0
  215. package/src/components/sections/PollBlock/index.astro +30 -0
  216. package/src/components/sections/Portfolio/featured.astro +343 -0
  217. package/src/components/sections/Portfolio/index.astro +571 -0
  218. package/src/components/sections/Portfolio/strip.astro +173 -0
  219. package/src/components/sections/Portfolio/work.ts +100 -0
  220. package/src/components/sections/Progress/MatchClock.astro +166 -0
  221. package/src/components/sections/Progress/compact.astro +150 -0
  222. package/src/components/sections/Progress/index.astro +32 -0
  223. package/src/components/sections/Progress/match.astro +126 -0
  224. package/src/components/sections/Progress/ring.astro +179 -0
  225. package/src/components/sections/QuickDonate/DonateCard.astro +149 -0
  226. package/src/components/sections/QuickDonate/Picker.astro +95 -0
  227. package/src/components/sections/QuickDonate/band.astro +164 -0
  228. package/src/components/sections/QuickDonate/bar.astro +208 -0
  229. package/src/components/sections/QuickDonate/donate.ts +126 -0
  230. package/src/components/sections/QuickDonate/hero.astro +143 -0
  231. package/src/components/sections/QuickDonate/index.astro +73 -0
  232. package/src/components/sections/QuickDonate/jar.astro +225 -0
  233. package/src/components/sections/QuickDonate/ladder.astro +248 -0
  234. package/src/components/sections/QuoteStrip/carousel.astro +340 -0
  235. package/src/components/sections/QuoteStrip/index.astro +58 -0
  236. package/src/components/sections/QuoteStrip/logos.astro +226 -0
  237. package/src/components/sections/QuoteStrip/quotes.ts +61 -0
  238. package/src/components/sections/QuoteStrip/single.astro +92 -0
  239. package/src/components/sections/QuoteStrip/ticker.astro +319 -0
  240. package/src/components/sections/QuoteStrip/wall.astro +113 -0
  241. package/src/components/sections/Resources/band.astro +93 -0
  242. package/src/components/sections/Resources/featured.astro +239 -0
  243. package/src/components/sections/Resources/index.astro +225 -0
  244. package/src/components/sections/Resources/resources.ts +92 -0
  245. package/src/components/sections/SampleBallot/Position.astro +39 -0
  246. package/src/components/sections/SampleBallot/ballot.ts +92 -0
  247. package/src/components/sections/SampleBallot/cards.astro +299 -0
  248. package/src/components/sections/SampleBallot/index.astro +326 -0
  249. package/src/components/sections/SampleBallot/measures.astro +172 -0
  250. package/src/components/sections/Scorecard/grades.astro +141 -0
  251. package/src/components/sections/Scorecard/index.astro +294 -0
  252. package/src/components/sections/Scorecard/promise.astro +167 -0
  253. package/src/components/sections/Scorecard/votes.ts +83 -0
  254. package/src/components/sections/SectionHead.astro +31 -0
  255. package/src/components/sections/Services/Button.astro +24 -0
  256. package/src/components/sections/Services/Check.astro +12 -0
  257. package/src/components/sections/Services/Includes.astro +42 -0
  258. package/src/components/sections/Services/compare.astro +328 -0
  259. package/src/components/sections/Services/index.astro +187 -0
  260. package/src/components/sections/Services/list.astro +181 -0
  261. package/src/components/sections/Services/services.ts +80 -0
  262. package/src/components/sections/ShareKit/Actions.astro +71 -0
  263. package/src/components/sections/ShareKit/Buttons.astro +62 -0
  264. package/src/components/sections/ShareKit/compact.astro +123 -0
  265. package/src/components/sections/ShareKit/index.astro +160 -0
  266. package/src/components/sections/ShareKit/share.ts +60 -0
  267. package/src/components/sections/ShareKit/strip.astro +173 -0
  268. package/src/components/sections/SignupCapture/band.astro +7 -0
  269. package/src/components/sections/SignupCapture/index.astro +103 -0
  270. package/src/components/sections/SignupCapture/inline.astro +7 -0
  271. package/src/components/sections/SocialFeed/index.astro +34 -0
  272. package/src/components/sections/StatCards/feature.astro +143 -0
  273. package/src/components/sections/StatCards/index.astro +51 -0
  274. package/src/components/sections/StatCards/ribbon.astro +113 -0
  275. package/src/components/sections/StatCards/wall.astro +177 -0
  276. package/src/components/sections/Store/featured.astro +14 -0
  277. package/src/components/sections/Store/index.astro +14 -0
  278. package/src/components/sections/Stories/Status.astro +42 -0
  279. package/src/components/sections/Stories/StoryCards.astro +171 -0
  280. package/src/components/sections/Stories/cards.astro +42 -0
  281. package/src/components/sections/Stories/index.astro +238 -0
  282. package/src/components/sections/Stories/stories.ts +97 -0
  283. package/src/components/sections/Stories/timeline.astro +135 -0
  284. package/src/components/sections/TeamGrid/board.astro +280 -0
  285. package/src/components/sections/TeamGrid/index.astro +71 -0
  286. package/src/components/sections/TeamGrid/list.astro +306 -0
  287. package/src/components/sections/TeamGrid/people.ts +178 -0
  288. package/src/components/sections/VideoEmbed/index.astro +52 -0
  289. package/src/components/sections/VideoEmbed/landscape.astro +7 -0
  290. package/src/components/sections/VideoEmbed/portrait.astro +7 -0
  291. package/src/components/sections/VideoEmbed/square.astro +7 -0
  292. package/src/components/sections/VoterTools/DaysLeft.astro +33 -0
  293. package/src/components/sections/VoterTools/dates.astro +149 -0
  294. package/src/components/sections/VoterTools/index.astro +228 -0
  295. package/src/components/sections/VoterTools/polling.astro +141 -0
  296. package/src/components/sections/VoterTools/voter-tools.ts +70 -0
  297. package/src/components/sections/index.ts +370 -0
  298. package/src/components/sections/modules/Headed.astro +39 -0
  299. package/src/components/sections/modules/ModuleFrame.astro +179 -0
  300. package/src/components/volunteer/ShiftLive.astro +90 -0
  301. package/src/components/volunteer/detail.astro +247 -0
  302. package/src/components/volunteer/list.astro +298 -0
  303. package/src/components/volunteer/props.ts +21 -0
  304. package/src/env.d.ts +22 -0
  305. package/src/index.d.ts +10 -0
  306. package/src/index.js +64 -0
  307. package/src/layouts/Site.astro +371 -0
  308. package/src/lib/academy.ts +146 -0
  309. package/src/lib/brand.ts +534 -0
  310. package/src/lib/chrome.ts +119 -0
  311. package/src/lib/donate-frame.ts +64 -0
  312. package/src/lib/entries.ts +190 -0
  313. package/src/lib/env.ts +34 -0
  314. package/src/lib/event-map-draw.ts +91 -0
  315. package/src/lib/events.ts +476 -0
  316. package/src/lib/fonts.ts +116 -0
  317. package/src/lib/footer.ts +24 -0
  318. package/src/lib/format.ts +160 -0
  319. package/src/lib/geo.ts +131 -0
  320. package/src/lib/live.ts +54 -0
  321. package/src/lib/menu.ts +48 -0
  322. package/src/lib/petition-text.ts +29 -0
  323. package/src/lib/reading.ts +17 -0
  324. package/src/lib/regions.ts +215 -0
  325. package/src/lib/section.ts +94 -0
  326. package/src/lib/shifts.ts +186 -0
  327. package/src/lib/stream-time.ts +20 -0
  328. package/src/lib/stream.ts +141 -0
  329. package/src/lib/visitor.ts +54 -0
  330. package/src/routes/catch-all.astro +286 -0
  331. package/src/routes/form.astro +30 -0
  332. package/src/routes/live.astro +49 -0
  333. package/src/routes/not-found.astro +18 -0
  334. package/src/routes/preview.astro +60 -0
  335. package/src/routes/setup.astro +62 -0
  336. package/src/routes/volunteer-shift.astro +61 -0
  337. package/src/routes/volunteer.astro +37 -0
  338. package/src/styles/entries.css +784 -0
  339. package/src/styles/site.css +1839 -0
  340. package/src/template.ts +182 -0
@@ -0,0 +1,361 @@
1
+ ---
2
+ // EventsList · Week (board 06, C, "Week calendar slots", without its
3
+ // picking: an event is signed up for on its own page): the section head (the
4
+ // kicker, the heading and the "All events" link), then the coming seven days
5
+ // as columns on the band's surface, each headed by its weekday over its day
6
+ // number (the month under the first day and any 1st), with the day's events
7
+ // under it as links to their pages on this site, which frame BackGold's RSVP
8
+ // and tickets: each its type and time over its title, and its live counts
9
+ // (filled in by LiveCounts after the page loads; empty without scripts). A
10
+ // day with no event keeps its column and says nothing.
11
+ //
12
+ // The page is cached, so the server cannot know which seven days are coming:
13
+ // it draws a column for each day the rows fall on (the event's own day, in
14
+ // its own time zone), in day order, and the section's script picks today in
15
+ // the visitor's own time, keeps the seven days from it (adding an empty
16
+ // column for each day with no event, dropping the rest), and rings today.
17
+ // When none of the seven has an event, the head stands over "Nothing this
18
+ // week." With scripts off the server's columns show: every upcoming day with
19
+ // an event, which is honest. An event with no readable date is left out: it
20
+ // has no day to sit in.
21
+ //
22
+ // On a phone the week is a list of days, each day's head at the left of its
23
+ // events. With neither a heading nor an event nothing is drawn.
24
+ import type { ComponentProps } from 'astro/types'
25
+ import type Default from './index.astro'
26
+ import Band from '../Band.astro'
27
+ import LiveCounts from './LiveCounts.astro'
28
+ import SectionHead from '../SectionHead.astro'
29
+ import { eventsOf, monthName, type EventRow } from './events'
30
+ import { links } from '../../../lib/section'
31
+ import { text } from '../../../lib/format'
32
+
33
+ type Props = ComponentProps<typeof Default>
34
+
35
+ const { section } = Astro.props
36
+ const heading = text(section.copy.heading)
37
+ const events = eventsOf(section)
38
+ const pad = (n: number) => String(n).padStart(2, '0')
39
+
40
+ interface Day {
41
+ /** "2026-10-17", the event's own calendar day. */
42
+ key: string
43
+ year: number
44
+ monthIndex: number
45
+ day: number
46
+ events: EventRow[]
47
+ }
48
+
49
+ // Rows arrive soonest first; a day gathers the rows that fall on it.
50
+ const days: Day[] = []
51
+ for (const event of events) {
52
+ if (!event.when) continue
53
+ const { year, monthIndex } = event.when
54
+ const day = Number(event.when.day)
55
+ const key = `${year}-${pad(monthIndex + 1)}-${pad(day)}`
56
+ const found = days.find((d) => d.key === key)
57
+ if (found) found.events.push(event)
58
+ else days.push({ key, year, monthIndex, day, events: [event] })
59
+ }
60
+ days.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
61
+
62
+ const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
63
+ const weekdayOf = (d: Day) => WEEKDAYS[new Date(Date.UTC(d.year, d.monthIndex, d.day)).getUTCDay()]!
64
+ // The month under the first column's day and under any day in a new month.
65
+ const showsMonth = (i: number) => i === 0 || days[i]!.monthIndex !== days[i - 1]!.monthIndex || days[i]!.year !== days[i - 1]!.year
66
+ const count = (n: number) => (n === 1 ? '1 event' : `${n} events`)
67
+ ---
68
+ {(heading || days.length > 0) && (
69
+ <Band section={section} class="events events-week">
70
+ <SectionHead kicker={text(section.copy.kicker)} heading={heading} more={links(section)} />
71
+ <div class="week" data-week>
72
+ {days.length > 0 && (
73
+ <ol class="wk-days" role="list">
74
+ {days.map((day, i) => (
75
+ <li class="wk-day" data-day={day.key}>
76
+ <h3 class="wk-head">
77
+ <time datetime={day.key}>
78
+ <span class="wk-weekday" aria-hidden="true">{weekdayOf(day).slice(0, 3)}</span>
79
+ <span class="wk-date" aria-hidden="true">
80
+ <b>{day.day}</b>
81
+ <span class="wk-month" hidden={!showsMonth(i)}>{monthName(day.monthIndex).slice(0, 3)}</span>
82
+ </span>
83
+ <span class="visually-hidden" data-week-label>{`${weekdayOf(day)}, ${monthName(day.monthIndex)} ${day.day}, ${count(day.events.length)}`}</span>
84
+ </time>
85
+ </h3>
86
+ <ul class="wk-events" role="list">
87
+ {day.events.map((event) => (
88
+ <li>
89
+ {event.link ? (
90
+ <a class="wk-event" href={event.link.href} rel={event.link.rel}>
91
+ {(event.type || event.when?.time) && <span class="wk-kind">{[event.type, event.when?.time].filter(Boolean).join(' · ')}</span>}
92
+ <span class="wk-title">{event.title}</span>
93
+ {event.id && <span class="wk-live" data-bg-live={event.id}></span>}
94
+ {event.closed && <span class="wk-closed">Registration closed</span>}
95
+ </a>
96
+ ) : (
97
+ <span class="wk-event">
98
+ {(event.type || event.when?.time) && <span class="wk-kind">{[event.type, event.when?.time].filter(Boolean).join(' · ')}</span>}
99
+ <span class="wk-title">{event.title}</span>
100
+ </span>
101
+ )}
102
+ </li>
103
+ ))}
104
+ </ul>
105
+ </li>
106
+ ))}
107
+ </ol>
108
+ )}
109
+ <p class="wk-empty" data-week-empty hidden={days.length > 0}>Nothing this week.</p>
110
+ {days.length > 0 && (
111
+ <template data-week-blank>
112
+ <li class="wk-day">
113
+ <h3 class="wk-head">
114
+ <time>
115
+ <span class="wk-weekday" aria-hidden="true"></span>
116
+ <span class="wk-date" aria-hidden="true"><b></b><span class="wk-month"></span></span>
117
+ <span class="visually-hidden" data-week-label></span>
118
+ </time>
119
+ </h3>
120
+ </li>
121
+ </template>
122
+ )}
123
+ {days.length > 0 && (
124
+ <script is:inline>
125
+ (function (root) {
126
+ if (!root) return
127
+ var list = root.querySelector('.wk-days')
128
+ var empty = root.querySelector('[data-week-empty]')
129
+ var blank = root.querySelector('template[data-week-blank]')
130
+ var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
131
+ var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
132
+ var pad = function (n) {
133
+ return (n < 10 ? '0' : '') + n
134
+ }
135
+ var byDay = {}
136
+ var columns = list.querySelectorAll('[data-day]')
137
+ for (var c = 0; c < columns.length; c++) byDay[columns[c].getAttribute('data-day')] = columns[c]
138
+ // The seven days from today, in the visitor's own time.
139
+ var now = new Date()
140
+ var week = []
141
+ var events = 0
142
+ for (var d = 0; d < 7; d++) {
143
+ var date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + d)
144
+ var key = date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate())
145
+ var column = byDay[key]
146
+ var n = column ? column.querySelectorAll('.wk-events > li').length : 0
147
+ if (!column) {
148
+ column = blank.content.firstElementChild.cloneNode(true)
149
+ column.setAttribute('data-day', key)
150
+ column.querySelector('time').setAttribute('datetime', key)
151
+ column.querySelector('.wk-weekday').textContent = WEEKDAYS[date.getDay()].slice(0, 3)
152
+ column.querySelector('b').textContent = String(date.getDate())
153
+ column.querySelector('.wk-month').textContent = MONTHS[date.getMonth()].slice(0, 3)
154
+ }
155
+ var label = WEEKDAYS[date.getDay()] + ', ' + MONTHS[date.getMonth()] + ' ' + date.getDate() + (d === 0 ? ', today' : '') + ', ' + (n === 0 ? 'no events' : n === 1 ? '1 event' : n + ' events')
156
+ column.querySelector('[data-week-label]').textContent = label
157
+ column.querySelector('.wk-month').hidden = !(d === 0 || date.getDate() === 1)
158
+ if (d === 0) {
159
+ column.classList.add('wk-today')
160
+ column.setAttribute('aria-current', 'date')
161
+ }
162
+ events += n
163
+ week.push(column)
164
+ }
165
+ for (var k in byDay) if (week.indexOf(byDay[k]) < 0) byDay[k].remove()
166
+ for (var w = 0; w < week.length; w++) list.appendChild(week[w])
167
+ list.hidden = events === 0
168
+ empty.hidden = events > 0
169
+ })(document.currentScript.closest('[data-week]'))
170
+ </script>
171
+ )}
172
+ </div>
173
+ <LiveCounts />
174
+ </Band>
175
+ )}
176
+
177
+ <style>
178
+ /* A phone: a list of days, each day's head at the left of its events. */
179
+ .wk-days {
180
+ display: grid;
181
+ margin: 0;
182
+ padding: 0;
183
+ list-style: none;
184
+ border: 1px solid var(--line);
185
+ border-radius: var(--radius-card);
186
+ background: var(--surface);
187
+ overflow: hidden;
188
+ }
189
+ .wk-days[hidden] {
190
+ display: none;
191
+ }
192
+ .wk-day {
193
+ display: grid;
194
+ grid-template-columns: 3.5rem minmax(0, 1fr);
195
+ gap: 0.875rem;
196
+ align-items: start;
197
+ min-width: 0;
198
+ padding: 0.875rem 1rem;
199
+ border-top: 1px solid var(--line);
200
+ }
201
+ .wk-day:first-child {
202
+ border-top: 0;
203
+ }
204
+ .wk-head {
205
+ margin: 0;
206
+ font: inherit;
207
+ letter-spacing: 0;
208
+ }
209
+ .wk-head time {
210
+ display: grid;
211
+ justify-items: center;
212
+ line-height: 1;
213
+ }
214
+ .wk-weekday {
215
+ color: var(--muted);
216
+ font-size: var(--text-xs);
217
+ font-weight: 700;
218
+ letter-spacing: 0.12em;
219
+ text-transform: uppercase;
220
+ }
221
+ .wk-date {
222
+ display: grid;
223
+ justify-items: center;
224
+ margin-top: 0.3125rem;
225
+ }
226
+ .wk-date b {
227
+ display: inline-grid;
228
+ place-items: center;
229
+ min-width: 2.375rem;
230
+ height: 2.375rem;
231
+ padding: 0 0.25rem;
232
+ border-radius: var(--pill);
233
+ font-family: var(--font-display);
234
+ font-size: 1.5rem;
235
+ font-weight: 800;
236
+ letter-spacing: -0.02em;
237
+ }
238
+ .wk-month {
239
+ margin-top: 0.125rem;
240
+ color: var(--accent);
241
+ font-size: 0.6875rem;
242
+ font-weight: 700;
243
+ letter-spacing: 0.12em;
244
+ text-transform: uppercase;
245
+ }
246
+ .wk-month[hidden] {
247
+ display: none;
248
+ }
249
+ /* Today: its day ringed, its weekday in the ink. */
250
+ .wk-today .wk-date b {
251
+ box-shadow: inset 0 0 0 2px var(--button);
252
+ }
253
+ .wk-today .wk-weekday {
254
+ color: var(--ink);
255
+ }
256
+ .wk-events {
257
+ display: grid;
258
+ gap: 0.5rem;
259
+ margin: 0;
260
+ padding: 0;
261
+ list-style: none;
262
+ }
263
+ .wk-event {
264
+ display: grid;
265
+ gap: 0.1875rem;
266
+ min-width: 0;
267
+ padding: 0.625rem 0.75rem 0.6875rem;
268
+ border: 1.5px solid color-mix(in srgb, var(--ink) 22%, transparent);
269
+ border-radius: var(--radius);
270
+ background: var(--surface);
271
+ color: var(--ink);
272
+ line-height: 1.3;
273
+ text-decoration: none;
274
+ }
275
+ a.wk-event:hover {
276
+ border-color: var(--ink);
277
+ }
278
+ a.wk-event:hover .wk-title {
279
+ text-decoration: underline;
280
+ }
281
+ .wk-kind {
282
+ color: var(--link);
283
+ font-size: 0.6875rem;
284
+ font-weight: 700;
285
+ letter-spacing: 0.05em;
286
+ text-transform: uppercase;
287
+ }
288
+ .wk-title {
289
+ font-size: var(--text-sm);
290
+ font-weight: 700;
291
+ }
292
+ .wk-live,
293
+ .wk-closed {
294
+ color: var(--muted);
295
+ font-size: var(--text-xs);
296
+ font-weight: 700;
297
+ }
298
+ .wk-live:empty {
299
+ display: none;
300
+ }
301
+ .wk-empty {
302
+ margin: 0;
303
+ padding: 1.125rem 1.25rem;
304
+ border: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
305
+ border-radius: var(--radius);
306
+ color: var(--ink);
307
+ font-family: var(--font-display);
308
+ font-size: var(--text-lg);
309
+ font-weight: 700;
310
+ }
311
+ .wk-empty[hidden] {
312
+ display: none;
313
+ }
314
+ /*
315
+ Wider: seven columns, each day's head over its events. Without scripts the
316
+ server's days run on in rows of seven.
317
+ */
318
+ @media (min-width: 48rem) {
319
+ .wk-days {
320
+ grid-template-columns: repeat(7, minmax(0, 1fr));
321
+ }
322
+ .wk-day {
323
+ grid-template-columns: minmax(0, 1fr);
324
+ align-content: start;
325
+ gap: 0.75rem;
326
+ min-height: 12rem;
327
+ padding: 0.875rem 0.5rem 1rem;
328
+ border-top: 0;
329
+ border-left: 1px solid var(--line);
330
+ }
331
+ .wk-day:nth-child(7n + 1) {
332
+ border-left: 0;
333
+ }
334
+ .wk-day:nth-child(n + 8) {
335
+ border-top: 1px solid var(--line);
336
+ }
337
+ .wk-head {
338
+ padding-bottom: 0.625rem;
339
+ border-bottom: 1px solid var(--line);
340
+ }
341
+ /* A month line kept in every head, so the seven heads end on one line. */
342
+ .wk-month[hidden] {
343
+ display: block;
344
+ visibility: hidden;
345
+ }
346
+ .wk-event {
347
+ padding: 0.5rem 0.5625rem 0.5625rem;
348
+ }
349
+ .wk-title {
350
+ font-size: 0.8125rem;
351
+ }
352
+ .wk-kind {
353
+ font-size: 0.625rem;
354
+ }
355
+ }
356
+ @media (prefers-reduced-motion: no-preference) {
357
+ a.wk-event {
358
+ transition: border-color 0.15s ease;
359
+ }
360
+ }
361
+ </style>
@@ -0,0 +1,63 @@
1
+ ---
2
+ // A Faq's way to ask what the list does not answer (board 07): the contact
3
+ // heading ("Still have a question?") with the one button beside it, which
4
+ // goes to the address the operator gave. `row` is a slim line under a rule,
5
+ // under the accordion; `panel` is C's filled panel in the contrast band's
6
+ // colours (on a section that is already on the contrast band, a tint of its
7
+ // ink). On a phone the button wraps under the heading. Draws nothing without
8
+ // the link.
9
+ import type { Contact } from './faq'
10
+
11
+ interface Props {
12
+ contact: Contact | null
13
+ look: 'row' | 'panel'
14
+ }
15
+
16
+ const { contact, look } = Astro.props
17
+ ---
18
+ {contact && (
19
+ <div class:list={['faq-contact', `faq-contact-${look}`, look === 'panel' && 'bg-band-contrast']}>
20
+ {contact.heading && <h3 class="faq-contact-heading">{contact.heading}</h3>}
21
+ <a class="button" href={contact.link.href} rel={contact.link.rel}>{contact.link.label}</a>
22
+ </div>
23
+ )}
24
+
25
+ <style>
26
+ .faq-contact {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ gap: 1rem 1.5rem;
32
+ margin-top: 1.75rem;
33
+ }
34
+ .faq-contact-heading {
35
+ flex: 1 1 14rem;
36
+ margin: 0;
37
+ font-size: var(--text-lg);
38
+ font-weight: 700;
39
+ line-height: 1.25;
40
+ }
41
+ .faq-contact-row {
42
+ padding-top: 1.5rem;
43
+ border-top: 1px solid var(--line);
44
+ }
45
+ .faq-contact-panel {
46
+ padding: 1.25rem 1.25rem 1.25rem 1.5rem;
47
+ border-radius: var(--radius-card);
48
+ background: var(--bg-band-background);
49
+ color: var(--bg-band-color);
50
+ }
51
+ :global(.bg-band-contrast) .faq-contact-panel {
52
+ border: 1px solid var(--line);
53
+ background: color-mix(in srgb, var(--ink) 7%, transparent);
54
+ }
55
+ @media (min-width: 40rem) {
56
+ .faq-contact-panel {
57
+ padding: 1.5rem 1.75rem 1.5rem 2rem;
58
+ }
59
+ .faq-contact-panel .faq-contact-heading {
60
+ font-size: var(--h3);
61
+ }
62
+ }
63
+ </style>
@@ -0,0 +1,98 @@
1
+ ---
2
+ // The Faq accordion (board 07, A and B's right column): one native
3
+ // <details> per question, each a card on the band's surface, the question
4
+ // in bold beside a chevron that points down, and turns up while the answer
5
+ // is open (in a turn, unless the visitor asks for reduced motion), the
6
+ // answer under it through Prose. The browser opens and closes them, with the
7
+ // keyboard too, so it works with scripts off. `firstOpen` starts the first
8
+ // answer open.
9
+ import Prose from '../../Prose.astro'
10
+ import type { Question } from './faq'
11
+
12
+ interface Props {
13
+ questions: Question[]
14
+ firstOpen?: boolean
15
+ }
16
+
17
+ const { questions, firstOpen = false } = Astro.props
18
+ ---
19
+ <div class="faq-questions">
20
+ {questions.map((q, i) => (
21
+ <details class="faq-question" open={firstOpen && i === 0}>
22
+ <summary>{q.question}</summary>
23
+ <Prose value={q.answer} class="faq-answer" />
24
+ </details>
25
+ ))}
26
+ </div>
27
+
28
+ <style>
29
+ .faq-questions {
30
+ display: grid;
31
+ gap: 0.625rem;
32
+ }
33
+ .faq-question {
34
+ border: 1px solid var(--line);
35
+ border-radius: var(--radius);
36
+ background: var(--surface);
37
+ }
38
+ .faq-question[open] {
39
+ border-color: var(--line-strong);
40
+ }
41
+ .faq-question summary {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: space-between;
45
+ gap: 1rem;
46
+ min-height: 3.25rem;
47
+ padding: 0.875rem 1.125rem;
48
+ border-radius: var(--radius);
49
+ color: var(--ink);
50
+ font-weight: 700;
51
+ line-height: 1.35;
52
+ list-style: none;
53
+ }
54
+ .faq-question summary::-webkit-details-marker {
55
+ display: none;
56
+ }
57
+ .faq-question summary:hover {
58
+ color: var(--link);
59
+ }
60
+ /* The chevron: right-angled borders, pointing down while closed and up once open. */
61
+ .faq-question summary::after {
62
+ content: '';
63
+ flex: 0 0 auto;
64
+ width: 0.5rem;
65
+ height: 0.5rem;
66
+ margin: -0.25rem 0.25rem 0 0;
67
+ border-right: 2px solid var(--link);
68
+ border-bottom: 2px solid var(--link);
69
+ transform: rotate(45deg);
70
+ }
71
+ .faq-question[open] summary::after {
72
+ margin-top: 0.25rem;
73
+ transform: rotate(225deg);
74
+ }
75
+ .faq-question :global(.faq-answer) {
76
+ padding: 0 1.125rem 1.125rem;
77
+ color: var(--muted);
78
+ }
79
+ .faq-question :global(.faq-answer > :last-child) {
80
+ margin-bottom: 0;
81
+ }
82
+ @media (prefers-reduced-motion: no-preference) {
83
+ .faq-question summary::after {
84
+ transition:
85
+ transform 0.2s ease,
86
+ margin 0.2s ease;
87
+ }
88
+ .faq-question[open] :global(.faq-answer) {
89
+ animation: faq-answer-in 0.2s ease-out;
90
+ }
91
+ }
92
+ @keyframes faq-answer-in {
93
+ from {
94
+ opacity: 0;
95
+ transform: translateY(-0.375rem);
96
+ }
97
+ }
98
+ </style>
@@ -0,0 +1,74 @@
1
+ ---
2
+ // Faq · Cards (board 07, C): the kicker, heading and line of copy, then every
3
+ // question as a card on the band's surface, two up (one on a phone), the
4
+ // question as the card's heading and the whole answer under it, nothing to
5
+ // open. The contact heading and its button close it in a filled panel in the
6
+ // contrast band's colours. The FAQPage JSON-LD goes with it as on every Faq
7
+ // layout. With no questions and no heading it draws nothing.
8
+ import type { ComponentProps } from 'astro/types'
9
+ import Band from '../Band.astro'
10
+ import SectionHead from '../SectionHead.astro'
11
+ import Prose from '../../Prose.astro'
12
+ import type Default from './index.astro'
13
+ import Contact from './Contact.astro'
14
+ import { contactOf, faqSchema, questionsOf } from './faq'
15
+ import { text } from '../../../lib/format'
16
+
17
+ type Props = ComponentProps<typeof Default>
18
+
19
+ const { section } = Astro.props
20
+ const kicker = text(section.copy.kicker)
21
+ const heading = text(section.copy.heading)
22
+ const questions = questionsOf(section)
23
+ const schema = faqSchema(questions)
24
+ ---
25
+ {(questions.length > 0 || heading) && (
26
+ <Band section={section} class="faq faq-cards">
27
+ <div class="faq-intro">
28
+ <SectionHead kicker={kicker} heading={heading} more={[]} />
29
+ <Prose value={section.copy.body} class="lede" />
30
+ </div>
31
+ {questions.length > 0 && (
32
+ <ul class="grid grid-2 faq-card-grid" role="list">
33
+ {questions.map((q) => (
34
+ <li class="faq-card">
35
+ <h3 class="faq-card-question">{q.question}</h3>
36
+ <Prose value={q.answer} class="faq-card-answer" />
37
+ </li>
38
+ ))}
39
+ </ul>
40
+ )}
41
+ <Contact contact={contactOf(section)} look="panel" />
42
+ {schema && <script is:inline type="application/ld+json" set:html={schema} />}
43
+ </Band>
44
+ )}
45
+
46
+ <style>
47
+ .faq-intro > :global(.lede) {
48
+ margin: -0.5rem 0 0;
49
+ }
50
+ .faq-card-grid {
51
+ gap: 1rem;
52
+ }
53
+ .faq-card {
54
+ padding: 1.25rem 1.375rem 1.375rem;
55
+ border: 1px solid var(--line);
56
+ border-radius: var(--radius);
57
+ background: var(--surface);
58
+ }
59
+ .faq-card-question {
60
+ margin: 0 0 0.5rem;
61
+ font-size: calc(var(--h3) * 0.9);
62
+ }
63
+ .faq-card :global(.faq-card-answer) {
64
+ color: var(--muted);
65
+ }
66
+ .faq-card :global(.faq-card-answer > :last-child) {
67
+ margin-bottom: 0;
68
+ }
69
+ @media (min-width: 40rem) {
70
+ .faq-card {
71
+ padding: 1.5rem 1.625rem 1.625rem;
72
+ }
73
+ }
74
+ </style>
@@ -0,0 +1,101 @@
1
+ // A Faq's rows as its layouts draw them. A row is drawn when it has both a
2
+ // question and an answer (a question with no answer is nothing to open). The
3
+ // answer stays the row's own value, drawn through Prose; its plain text goes
4
+ // into the FAQPage JSON-LD every layout writes, so search reads the same
5
+ // questions and answers the page shows. `topicsOf` groups the rows by their
6
+ // `topic` in the order each topic first appears, with the rows that have none
7
+ // last under "Other"; it is empty when no row has a topic.
8
+
9
+ import type { Section } from '@backgold/content'
10
+ import { serializeJsonLd } from '@backgold/astro/server'
11
+ import { links, rows, type Link } from '../../../lib/section'
12
+ import { prose, text } from '../../../lib/format'
13
+
14
+ export interface Question {
15
+ question: string
16
+ /** The row's answer as BackGold sends it: rich text or plain paragraphs, for Prose. */
17
+ answer: unknown
18
+ /** The answer as plain text, paragraphs a blank line apart. */
19
+ answerText: string
20
+ topic: string | null
21
+ }
22
+
23
+ export interface Topic {
24
+ /** "1", "2", … in nav order: what the topic buttons and their groups are matched by. */
25
+ key: string
26
+ label: string
27
+ questions: Question[]
28
+ }
29
+
30
+ export interface Contact {
31
+ heading: string | null
32
+ link: Link
33
+ }
34
+
35
+ const ENTITIES: Record<string, string> = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' }
36
+
37
+ /** Sanitized rich text as plain text: tags dropped, a paragraph or list item ending a line, entities decoded. */
38
+ function plainText(html: string): string {
39
+ return html
40
+ .replace(/<(?:br|\/p|\/li|\/h[23]|\/blockquote)\b[^>]*>/gi, '\n')
41
+ .replace(/<[^>]*>/g, '')
42
+ .replace(/&(?:#(\d+)|#x([0-9a-f]+)|([a-z]+));/gi, (whole, dec: string, hex: string, name: string) =>
43
+ dec ? String.fromCodePoint(Number(dec)) : hex ? String.fromCodePoint(parseInt(hex, 16)) : (ENTITIES[name.toLowerCase()] ?? whole),
44
+ )
45
+ .split('\n')
46
+ .map((line) => line.trim())
47
+ .filter(Boolean)
48
+ .join('\n\n')
49
+ }
50
+
51
+ export function questionsOf(section: Section): Question[] {
52
+ return rows(section).flatMap((row) => {
53
+ const question = text(row.question)?.trim()
54
+ const body = prose(row.answer)
55
+ const answerText = body ? ('html' in body ? plainText(body.html) : body.paragraphs.join('\n\n')) : ''
56
+ if (!question || !answerText) return []
57
+ return [{ question, answer: row.answer, answerText, topic: text(row.topic)?.trim() ?? null }]
58
+ })
59
+ }
60
+
61
+ export function topicsOf(questions: Question[]): Topic[] {
62
+ if (!questions.some((q) => q.topic)) return []
63
+ const topics: Topic[] = []
64
+ const other: Question[] = []
65
+ for (const q of questions) {
66
+ if (!q.topic) {
67
+ other.push(q)
68
+ continue
69
+ }
70
+ let topic = topics.find((t) => t.label === q.topic)
71
+ if (!topic) {
72
+ topic = { key: '', label: q.topic, questions: [] }
73
+ topics.push(topic)
74
+ }
75
+ topic.questions.push(q)
76
+ }
77
+ if (other.length > 0) topics.push({ key: '', label: 'Other', questions: other })
78
+ return topics.map((t, i) => ({ ...t, key: String(i + 1) }))
79
+ }
80
+
81
+ /** The contact line's link, labelled `contactLabel`, with `contactHeading` beside it; null without the link. */
82
+ export function contactOf(section: Section): Contact | null {
83
+ const link = links(section)[0]
84
+ return link ? { heading: text(section.copy.contactHeading), link } : null
85
+ }
86
+
87
+ /** The FAQPage JSON-LD for the questions, ready for a `<script type="application/ld+json">`; null with none. */
88
+ export function faqSchema(questions: Question[]): string | null {
89
+ if (questions.length === 0) return null
90
+ return serializeJsonLd([
91
+ {
92
+ '@context': 'https://schema.org',
93
+ '@type': 'FAQPage',
94
+ mainEntity: questions.map((q) => ({
95
+ '@type': 'Question',
96
+ name: q.question,
97
+ acceptedAnswer: { '@type': 'Answer', text: q.answerText },
98
+ })),
99
+ },
100
+ ])
101
+ }