@backgold/template-kit 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/chunk-RJAVFRC6.js +67 -0
- package/dist/constants-BAIo_Q5U.d-lQbj1e1-.d.ts +48 -0
- package/dist/content-api-Cox1-wz5.d.ts +1096 -0
- package/dist/contract/content-api-examples.d.ts +72 -0
- package/dist/contract/content-api-examples.js +926 -0
- package/dist/contract/content-api.d.ts +2 -0
- package/dist/contract/content-api.js +1 -0
- package/dist/contract/site-templates.d.ts +253 -0
- package/dist/contract/site-templates.js +185 -0
- package/package.json +70 -3
- package/src/components/EntryCard.astro +35 -0
- package/src/components/EventMap.astro +118 -0
- package/src/components/EventPage.astro +194 -0
- package/src/components/FieldValue.astro +41 -0
- package/src/components/LeadingHero.astro +21 -0
- package/src/components/NotFound.astro +20 -0
- package/src/components/PageSections.astro +47 -0
- package/src/components/Prose.astro +18 -0
- package/src/components/chrome/Brand.astro +61 -0
- package/src/components/chrome/ClosingCall.astro +94 -0
- package/src/components/chrome/DonateStrip.astro +61 -0
- package/src/components/chrome/FooterColumns.astro +32 -0
- package/src/components/chrome/FooterContact.astro +28 -0
- package/src/components/chrome/MenuList.astro +45 -0
- package/src/components/chrome/ModeToggle.astro +125 -0
- package/src/components/chrome/SignedInNotice.astro +53 -0
- package/src/components/chrome/SignupBand.astro +12 -0
- package/src/components/chrome/TakeoverBanner.astro +56 -0
- package/src/components/chrome/VisitorAccount.astro +82 -0
- package/src/components/entries/AuthorBox.astro +47 -0
- package/src/components/entries/EntryFields.astro +29 -0
- package/src/components/entries/EntryHeader.astro +77 -0
- package/src/components/entries/ListFrame.astro +126 -0
- package/src/components/entries/ListSearch.astro +24 -0
- package/src/components/entries/Share.astro +24 -0
- package/src/components/entries/course/classroom.astro +26 -0
- package/src/components/entries/course/lesson.astro +18 -0
- package/src/components/entries/course/section.ts +20 -0
- package/src/components/entries/course/syllabus.astro +15 -0
- package/src/components/entries/index.ts +77 -0
- package/src/components/entries/newsletter/issue.astro +41 -0
- package/src/components/entries/newsletter/list.astro +26 -0
- package/src/components/entries/podcast/episode.astro +42 -0
- package/src/components/entries/podcast/list.astro +36 -0
- package/src/components/entries/post/article.astro +31 -0
- package/src/components/entries/post/list.astro +85 -0
- package/src/components/entries/props.ts +61 -0
- package/src/components/entries/video/cards.astro +39 -0
- package/src/components/entries/video/grid.astro +15 -0
- package/src/components/entries/video/watch.astro +41 -0
- package/src/components/live/LivePage.astro +215 -0
- package/src/components/live/LocalTime.astro +29 -0
- package/src/components/sections/About/books.astro +188 -0
- package/src/components/sections/About/credentials.ts +80 -0
- package/src/components/sections/About/index.astro +60 -0
- package/src/components/sections/About/left.astro +57 -0
- package/src/components/sections/About/letter.astro +111 -0
- package/src/components/sections/About/portrait.astro +308 -0
- package/src/components/sections/Advocacy/compact.astro +14 -0
- package/src/components/sections/Advocacy/index.astro +14 -0
- package/src/components/sections/Band.astro +39 -0
- package/src/components/sections/Blog/feature.astro +176 -0
- package/src/components/sections/Blog/index.astro +37 -0
- package/src/components/sections/Blog/latest.ts +80 -0
- package/src/components/sections/Blog/list.astro +186 -0
- package/src/components/sections/Booking/index.astro +139 -0
- package/src/components/sections/Booking/list.astro +144 -0
- package/src/components/sections/Booking/types.ts +60 -0
- package/src/components/sections/Calendar/agenda.astro +14 -0
- package/src/components/sections/Calendar/index.astro +14 -0
- package/src/components/sections/CandidateRoster/ballot.astro +394 -0
- package/src/components/sections/CandidateRoster/candidates.ts +69 -0
- package/src/components/sections/CandidateRoster/compact.astro +115 -0
- package/src/components/sections/CandidateRoster/index.astro +57 -0
- package/src/components/sections/CaseStudies/beforeafter.astro +222 -0
- package/src/components/sections/CaseStudies/cases.ts +111 -0
- package/src/components/sections/CaseStudies/grid.astro +261 -0
- package/src/components/sections/CaseStudies/index.astro +333 -0
- package/src/components/sections/Classroom/CourseCard.astro +181 -0
- package/src/components/sections/Classroom/Courses.astro +88 -0
- package/src/components/sections/Classroom/classroom.ts +141 -0
- package/src/components/sections/Classroom/index.astro +20 -0
- package/src/components/sections/Classroom/list.astro +15 -0
- package/src/components/sections/Collection/compact.astro +7 -0
- package/src/components/sections/Collection/entries.ts +62 -0
- package/src/components/sections/Collection/feature.astro +180 -0
- package/src/components/sections/Collection/index.astro +46 -0
- package/src/components/sections/Collection/library.astro +271 -0
- package/src/components/sections/Collection/list.astro +7 -0
- package/src/components/sections/Collection/outline.astro +134 -0
- package/src/components/sections/Collection/shelves.astro +191 -0
- package/src/components/sections/Comparison/Unlisted.astro +6 -0
- package/src/components/sections/Comparison/cards.astro +171 -0
- package/src/components/sections/Comparison/index.astro +191 -0
- package/src/components/sections/Comparison/sides.ts +98 -0
- package/src/components/sections/Comparison/spectrum.astro +261 -0
- package/src/components/sections/ContentPost/banner.astro +152 -0
- package/src/components/sections/ContentPost/index.astro +35 -0
- package/src/components/sections/ContentPost/lesson.ts +126 -0
- package/src/components/sections/ContentPost/player.astro +254 -0
- package/src/components/sections/ContentPost/prose.astro +80 -0
- package/src/components/sections/ContentPost/theater.astro +329 -0
- package/src/components/sections/Countdown/index.astro +53 -0
- package/src/components/sections/Course/Bar.astro +46 -0
- package/src/components/sections/Course/CourseHead.astro +123 -0
- package/src/components/sections/Course/Crumbs.astro +44 -0
- package/src/components/sections/Course/Icon.astro +29 -0
- package/src/components/sections/Course/Ring.astro +62 -0
- package/src/components/sections/Course/Syllabus.astro +146 -0
- package/src/components/sections/Course/course.ts +146 -0
- package/src/components/sections/Course/index.astro +143 -0
- package/src/components/sections/Course/outline.astro +39 -0
- package/src/components/sections/Cta/banner.astro +64 -0
- package/src/components/sections/Cta/card.astro +88 -0
- package/src/components/sections/Cta/index.astro +31 -0
- package/src/components/sections/Cta/photo.astro +114 -0
- package/src/components/sections/Cta/strip.astro +91 -0
- package/src/components/sections/Donate/index.astro +136 -0
- package/src/components/sections/Donate/story.astro +7 -0
- package/src/components/sections/Event/card.astro +14 -0
- package/src/components/sections/Event/index.astro +14 -0
- package/src/components/sections/EventsList/AgendaMonths.astro +105 -0
- package/src/components/sections/EventsList/CalendarLine.astro +23 -0
- package/src/components/sections/EventsList/EventRows.astro +196 -0
- package/src/components/sections/EventsList/LiveCounts.astro +75 -0
- package/src/components/sections/EventsList/TypeTabs.astro +53 -0
- package/src/components/sections/EventsList/agenda.astro +55 -0
- package/src/components/sections/EventsList/calendar.astro +392 -0
- package/src/components/sections/EventsList/cards.astro +186 -0
- package/src/components/sections/EventsList/cohorts.astro +205 -0
- package/src/components/sections/EventsList/compact.astro +163 -0
- package/src/components/sections/EventsList/events.ts +168 -0
- package/src/components/sections/EventsList/index.astro +46 -0
- package/src/components/sections/EventsList/map.astro +436 -0
- package/src/components/sections/EventsList/shifts.astro +355 -0
- package/src/components/sections/EventsList/week.astro +361 -0
- package/src/components/sections/Faq/Contact.astro +63 -0
- package/src/components/sections/Faq/Questions.astro +98 -0
- package/src/components/sections/Faq/cards.astro +74 -0
- package/src/components/sections/Faq/faq.ts +101 -0
- package/src/components/sections/Faq/index.astro +49 -0
- package/src/components/sections/Faq/topics.astro +178 -0
- package/src/components/sections/Financials/Foot.astro +38 -0
- package/src/components/sections/Financials/Head.astro +47 -0
- package/src/components/sections/Financials/donut.astro +197 -0
- package/src/components/sections/Financials/financials.ts +52 -0
- package/src/components/sections/Financials/index.astro +148 -0
- package/src/components/sections/Financials/table.astro +157 -0
- package/src/components/sections/FormBlock/index.astro +33 -0
- package/src/components/sections/FormBlock/wide.astro +7 -0
- package/src/components/sections/Hero/cover.astro +176 -0
- package/src/components/sections/Hero/donate.astro +209 -0
- package/src/components/sections/Hero/field.astro +390 -0
- package/src/components/sections/Hero/index.astro +52 -0
- package/src/components/sections/Hero/overlap.astro +151 -0
- package/src/components/sections/Hero/rotating.astro +30 -0
- package/src/components/sections/Hero/split.astro +99 -0
- package/src/components/sections/Hero/statement.astro +55 -0
- package/src/components/sections/Hero/video.astro +399 -0
- package/src/components/sections/Issues/checklist.astro +204 -0
- package/src/components/sections/Issues/drawer.astro +237 -0
- package/src/components/sections/Issues/index.astro +115 -0
- package/src/components/sections/Issues/issues.ts +37 -0
- package/src/components/sections/Issues/numbered.astro +79 -0
- package/src/components/sections/Issues/rows.astro +137 -0
- package/src/components/sections/Issues/steps.astro +81 -0
- package/src/components/sections/Issues/tabs.astro +322 -0
- package/src/components/sections/Leaderboard/index.astro +29 -0
- package/src/components/sections/Lesson/Door.astro +121 -0
- package/src/components/sections/Lesson/LessonBody.astro +416 -0
- package/src/components/sections/Lesson/Rail.astro +182 -0
- package/src/components/sections/Lesson/Tracker.astro +137 -0
- package/src/components/sections/Lesson/index.astro +27 -0
- package/src/components/sections/Lesson/lesson.ts +233 -0
- package/src/components/sections/Lesson/reading.astro +21 -0
- package/src/components/sections/Map/CoverageLine.astro +19 -0
- package/src/components/sections/Map/RegionMap.astro +109 -0
- package/src/components/sections/Map/bar.astro +160 -0
- package/src/components/sections/Map/index.astro +192 -0
- package/src/components/sections/Map/map.astro +275 -0
- package/src/components/sections/MediaKit/BioCard.astro +108 -0
- package/src/components/sections/MediaKit/Downloads.astro +88 -0
- package/src/components/sections/MediaKit/index.astro +183 -0
- package/src/components/sections/MediaKit/kit.ts +140 -0
- package/src/components/sections/MediaKit/press.astro +189 -0
- package/src/components/sections/MediaKit/speaker.astro +205 -0
- package/src/components/sections/Membership/Benefits.astro +42 -0
- package/src/components/sections/Membership/Check.astro +12 -0
- package/src/components/sections/Membership/Price.astro +61 -0
- package/src/components/sections/Membership/compare.astro +312 -0
- package/src/components/sections/Membership/index.astro +281 -0
- package/src/components/sections/Membership/offers.ts +169 -0
- package/src/components/sections/Membership/tiers.astro +217 -0
- package/src/components/sections/MovementMap/index.astro +50 -0
- package/src/components/sections/MovementTicker/index.astro +43 -0
- package/src/components/sections/Pathways/Doors.astro +147 -0
- package/src/components/sections/Pathways/Head.astro +37 -0
- package/src/components/sections/Pathways/index.astro +27 -0
- package/src/components/sections/Pathways/pathways.ts +100 -0
- package/src/components/sections/Pathways/quiz.astro +286 -0
- package/src/components/sections/Pathways/tabs.astro +271 -0
- package/src/components/sections/PdfEmbed/card.astro +99 -0
- package/src/components/sections/PdfEmbed/index.astro +26 -0
- package/src/components/sections/PdfEmbed/medium.astro +7 -0
- package/src/components/sections/PdfEmbed/tall.astro +7 -0
- package/src/components/sections/Petition/coverage.astro +14 -0
- package/src/components/sections/Petition/image.astro +14 -0
- package/src/components/sections/Petition/index.astro +14 -0
- package/src/components/sections/Petition/map.astro +14 -0
- package/src/components/sections/PlatformPlanks/anchors.ts +66 -0
- package/src/components/sections/PlatformPlanks/columns.astro +171 -0
- package/src/components/sections/PlatformPlanks/index.astro +56 -0
- package/src/components/sections/PlatformPlanks/longread.astro +250 -0
- package/src/components/sections/PollBlock/index.astro +30 -0
- package/src/components/sections/Portfolio/featured.astro +343 -0
- package/src/components/sections/Portfolio/index.astro +571 -0
- package/src/components/sections/Portfolio/strip.astro +173 -0
- package/src/components/sections/Portfolio/work.ts +100 -0
- package/src/components/sections/Progress/MatchClock.astro +166 -0
- package/src/components/sections/Progress/compact.astro +150 -0
- package/src/components/sections/Progress/index.astro +32 -0
- package/src/components/sections/Progress/match.astro +126 -0
- package/src/components/sections/Progress/ring.astro +179 -0
- package/src/components/sections/QuickDonate/DonateCard.astro +149 -0
- package/src/components/sections/QuickDonate/Picker.astro +95 -0
- package/src/components/sections/QuickDonate/band.astro +164 -0
- package/src/components/sections/QuickDonate/bar.astro +208 -0
- package/src/components/sections/QuickDonate/donate.ts +126 -0
- package/src/components/sections/QuickDonate/hero.astro +143 -0
- package/src/components/sections/QuickDonate/index.astro +73 -0
- package/src/components/sections/QuickDonate/jar.astro +225 -0
- package/src/components/sections/QuickDonate/ladder.astro +248 -0
- package/src/components/sections/QuoteStrip/carousel.astro +340 -0
- package/src/components/sections/QuoteStrip/index.astro +58 -0
- package/src/components/sections/QuoteStrip/logos.astro +226 -0
- package/src/components/sections/QuoteStrip/quotes.ts +61 -0
- package/src/components/sections/QuoteStrip/single.astro +92 -0
- package/src/components/sections/QuoteStrip/ticker.astro +319 -0
- package/src/components/sections/QuoteStrip/wall.astro +113 -0
- package/src/components/sections/Resources/band.astro +93 -0
- package/src/components/sections/Resources/featured.astro +239 -0
- package/src/components/sections/Resources/index.astro +225 -0
- package/src/components/sections/Resources/resources.ts +92 -0
- package/src/components/sections/SampleBallot/Position.astro +39 -0
- package/src/components/sections/SampleBallot/ballot.ts +92 -0
- package/src/components/sections/SampleBallot/cards.astro +299 -0
- package/src/components/sections/SampleBallot/index.astro +326 -0
- package/src/components/sections/SampleBallot/measures.astro +172 -0
- package/src/components/sections/Scorecard/grades.astro +141 -0
- package/src/components/sections/Scorecard/index.astro +294 -0
- package/src/components/sections/Scorecard/promise.astro +167 -0
- package/src/components/sections/Scorecard/votes.ts +83 -0
- package/src/components/sections/SectionHead.astro +31 -0
- package/src/components/sections/Services/Button.astro +24 -0
- package/src/components/sections/Services/Check.astro +12 -0
- package/src/components/sections/Services/Includes.astro +42 -0
- package/src/components/sections/Services/compare.astro +328 -0
- package/src/components/sections/Services/index.astro +187 -0
- package/src/components/sections/Services/list.astro +181 -0
- package/src/components/sections/Services/services.ts +80 -0
- package/src/components/sections/ShareKit/Actions.astro +71 -0
- package/src/components/sections/ShareKit/Buttons.astro +62 -0
- package/src/components/sections/ShareKit/compact.astro +123 -0
- package/src/components/sections/ShareKit/index.astro +160 -0
- package/src/components/sections/ShareKit/share.ts +60 -0
- package/src/components/sections/ShareKit/strip.astro +173 -0
- package/src/components/sections/SignupCapture/band.astro +7 -0
- package/src/components/sections/SignupCapture/index.astro +103 -0
- package/src/components/sections/SignupCapture/inline.astro +7 -0
- package/src/components/sections/SocialFeed/index.astro +34 -0
- package/src/components/sections/StatCards/feature.astro +143 -0
- package/src/components/sections/StatCards/index.astro +51 -0
- package/src/components/sections/StatCards/ribbon.astro +113 -0
- package/src/components/sections/StatCards/wall.astro +177 -0
- package/src/components/sections/Store/featured.astro +14 -0
- package/src/components/sections/Store/index.astro +14 -0
- package/src/components/sections/Stories/Status.astro +42 -0
- package/src/components/sections/Stories/StoryCards.astro +171 -0
- package/src/components/sections/Stories/cards.astro +42 -0
- package/src/components/sections/Stories/index.astro +238 -0
- package/src/components/sections/Stories/stories.ts +97 -0
- package/src/components/sections/Stories/timeline.astro +135 -0
- package/src/components/sections/TeamGrid/board.astro +280 -0
- package/src/components/sections/TeamGrid/index.astro +71 -0
- package/src/components/sections/TeamGrid/list.astro +306 -0
- package/src/components/sections/TeamGrid/people.ts +178 -0
- package/src/components/sections/VideoEmbed/index.astro +52 -0
- package/src/components/sections/VideoEmbed/landscape.astro +7 -0
- package/src/components/sections/VideoEmbed/portrait.astro +7 -0
- package/src/components/sections/VideoEmbed/square.astro +7 -0
- package/src/components/sections/VoterTools/DaysLeft.astro +33 -0
- package/src/components/sections/VoterTools/Lookup.astro +43 -0
- package/src/components/sections/VoterTools/dates.astro +153 -0
- package/src/components/sections/VoterTools/index.astro +231 -0
- package/src/components/sections/VoterTools/polling.astro +144 -0
- package/src/components/sections/VoterTools/voter-tools.ts +71 -0
- package/src/components/sections/index.ts +373 -0
- package/src/components/sections/modules/Headed.astro +39 -0
- package/src/components/sections/modules/ModuleFrame.astro +181 -0
- package/src/components/store/CollectionPage.astro +40 -0
- package/src/components/store/ProductCard.astro +32 -0
- package/src/components/store/ProductGrid.astro +16 -0
- package/src/components/store/ProductPage.astro +146 -0
- package/src/components/store/StorePage.astro +137 -0
- package/src/components/store/StoreScript.astro +572 -0
- package/src/components/volunteer/ShiftLive.astro +90 -0
- package/src/components/volunteer/detail.astro +247 -0
- package/src/components/volunteer/list.astro +298 -0
- package/src/components/volunteer/props.ts +21 -0
- package/src/env.d.ts +22 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +63 -0
- package/src/layouts/Site.astro +387 -0
- package/src/lib/academy.ts +146 -0
- package/src/lib/brand.ts +534 -0
- package/src/lib/chrome.ts +121 -0
- package/src/lib/donate-frame.ts +104 -0
- package/src/lib/entries.ts +190 -0
- package/src/lib/env.ts +34 -0
- package/src/lib/event-map-draw.ts +91 -0
- package/src/lib/events.ts +476 -0
- package/src/lib/fonts.ts +116 -0
- package/src/lib/footer.ts +24 -0
- package/src/lib/format.ts +160 -0
- package/src/lib/geo.ts +131 -0
- package/src/lib/live.ts +55 -0
- package/src/lib/menu.ts +48 -0
- package/src/lib/petition-text.ts +29 -0
- package/src/lib/reading.ts +17 -0
- package/src/lib/regions.ts +215 -0
- package/src/lib/section.ts +105 -0
- package/src/lib/shifts.ts +187 -0
- package/src/lib/store.ts +521 -0
- package/src/lib/stream-time.ts +20 -0
- package/src/lib/stream.ts +141 -0
- package/src/lib/visitor.ts +54 -0
- package/src/routes/catch-all.astro +435 -0
- package/src/routes/form.astro +30 -0
- package/src/routes/live.astro +49 -0
- package/src/routes/not-found.astro +18 -0
- package/src/routes/preview.astro +60 -0
- package/src/routes/setup.astro +62 -0
- package/src/routes/volunteer-shift.astro +61 -0
- package/src/styles/entries.css +784 -0
- package/src/styles/site.css +1910 -0
- package/src/styles/store.css +634 -0
- package/src/template.ts +182 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// A Classroom's courses as its grid and list layouts draw them (board D1).
|
|
2
|
+
//
|
|
3
|
+
// The courses come from the section's data rows (the bake's `courses`
|
|
4
|
+
// source: public, cached, the same for every reader) or, on the courses list
|
|
5
|
+
// page, from `GET /courses`. Neither knows who is reading. While a visitor is
|
|
6
|
+
// signed in, `GET /courses` read as that visitor (lib/visitor.ts) lays each
|
|
7
|
+
// course's progress and lock over its card, matched by slug; signed out, a
|
|
8
|
+
// card says what it takes to watch instead of drawing a bar that would
|
|
9
|
+
// always read zero.
|
|
10
|
+
|
|
11
|
+
import type { Section } from '@backgold/content'
|
|
12
|
+
import type { ContentAccessLevel, CourseProgress, CourseSummary, EntryLock, Visitor } from '#contract/content-api'
|
|
13
|
+
import { safeHref, safeSrc, signInHref } from '@backgold/astro/server'
|
|
14
|
+
import { rows } from '../../../lib/section'
|
|
15
|
+
import { text } from '../../../lib/format'
|
|
16
|
+
import { isAccess, stateOf } from '../../../lib/academy'
|
|
17
|
+
import { academyReads } from '../../../lib/visitor'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One row of a Classroom section's data as the bake sends it: flat, like a
|
|
21
|
+
* Collection's rows, with no progress and no lock detail (those come from
|
|
22
|
+
* the visitor's own read).
|
|
23
|
+
*/
|
|
24
|
+
export interface ClassroomRow {
|
|
25
|
+
slug: string
|
|
26
|
+
title: string
|
|
27
|
+
summary: string | null
|
|
28
|
+
url: string | null
|
|
29
|
+
hero_url: string | null
|
|
30
|
+
lesson_count: number
|
|
31
|
+
total_seconds: number | null
|
|
32
|
+
access: ContentAccessLevel
|
|
33
|
+
locked: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CourseCard {
|
|
37
|
+
slug: string
|
|
38
|
+
title: string
|
|
39
|
+
summary: string | null
|
|
40
|
+
href: string | null
|
|
41
|
+
cover: string | null
|
|
42
|
+
lessons: number
|
|
43
|
+
seconds: number | null
|
|
44
|
+
access: ContentAccessLevel
|
|
45
|
+
locked: boolean
|
|
46
|
+
lock: EntryLock | null
|
|
47
|
+
/** This visitor's place in the course; null signed out. */
|
|
48
|
+
progress: CourseProgress | null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface Classroom {
|
|
52
|
+
kicker: string | null
|
|
53
|
+
heading: string | null
|
|
54
|
+
cards: CourseCard[]
|
|
55
|
+
visitor: Visitor | null
|
|
56
|
+
/** The organization's name, for a members card's "Join <org> to start this course." */
|
|
57
|
+
orgName: string | null
|
|
58
|
+
/** "You have finished 1 of 6 courses and have 3 under way.", with a visitor and a course. */
|
|
59
|
+
summary: { finished: number; total: number; started: number } | null
|
|
60
|
+
/** The sign-in door, back to this page; signed out only. */
|
|
61
|
+
signIn: string | null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const count = (value: unknown): number => (typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.round(value) : 0)
|
|
65
|
+
const seconds = (value: unknown): number | null => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : null)
|
|
66
|
+
|
|
67
|
+
function cardOfRow(row: { [K in keyof ClassroomRow]?: unknown }): CourseCard | null {
|
|
68
|
+
const title = text(row.title)
|
|
69
|
+
const slug = text(row.slug)
|
|
70
|
+
if (!title || !slug) return null
|
|
71
|
+
return {
|
|
72
|
+
slug,
|
|
73
|
+
title,
|
|
74
|
+
summary: text(row.summary),
|
|
75
|
+
href: safeHref(row.url),
|
|
76
|
+
cover: safeSrc(row.hero_url),
|
|
77
|
+
lessons: count(row.lesson_count),
|
|
78
|
+
seconds: seconds(row.total_seconds),
|
|
79
|
+
access: isAccess(row.access) ? row.access : 'public',
|
|
80
|
+
locked: row.locked === true,
|
|
81
|
+
lock: null,
|
|
82
|
+
progress: null,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function cardOfSummary(course: CourseSummary): CourseCard {
|
|
87
|
+
return {
|
|
88
|
+
slug: course.slug,
|
|
89
|
+
title: course.title,
|
|
90
|
+
summary: course.summary,
|
|
91
|
+
href: safeHref(course.url),
|
|
92
|
+
cover: course.hero ? safeSrc(course.hero.url) : null,
|
|
93
|
+
lessons: course.lesson_count,
|
|
94
|
+
seconds: course.total_seconds,
|
|
95
|
+
access: course.access,
|
|
96
|
+
locked: course.locked,
|
|
97
|
+
lock: course.lock,
|
|
98
|
+
progress: course.progress,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The section's classroom. `from: 'rows'` draws the section's data rows (a
|
|
104
|
+
* Classroom placed on a page); `from: 'read'` reads `GET /courses` (the
|
|
105
|
+
* courses list page, which has no baked rows).
|
|
106
|
+
*/
|
|
107
|
+
export async function classroomOf(
|
|
108
|
+
section: Section,
|
|
109
|
+
astro: { locals: App.Locals; url: URL },
|
|
110
|
+
from: 'rows' | 'read' = 'rows',
|
|
111
|
+
): Promise<Classroom> {
|
|
112
|
+
const reads = academyReads(astro)
|
|
113
|
+
const { visitor } = reads
|
|
114
|
+
let cards: CourseCard[]
|
|
115
|
+
if (from === 'read') {
|
|
116
|
+
cards = ((await reads.courses())?.courses ?? []).map(cardOfSummary)
|
|
117
|
+
} else {
|
|
118
|
+
cards = rows(section).flatMap((row) => cardOfRow(row) ?? [])
|
|
119
|
+
if (visitor && cards.length > 0) {
|
|
120
|
+
const mine = new Map(((await reads.courses())?.courses ?? []).map((c) => [c.slug, c]))
|
|
121
|
+
cards = cards.map((card) => {
|
|
122
|
+
const own = mine.get(card.slug)
|
|
123
|
+
return own ? { ...card, locked: own.locked, lock: own.lock, progress: own.progress } : card
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const tracked = visitor ? cards.filter((c) => !c.locked && c.progress) : []
|
|
128
|
+
const states = tracked.map((c) => stateOf(c.progress!))
|
|
129
|
+
return {
|
|
130
|
+
kicker: text(section.copy.kicker),
|
|
131
|
+
heading: text(section.copy.heading),
|
|
132
|
+
cards,
|
|
133
|
+
visitor,
|
|
134
|
+
orgName: reads.orgName,
|
|
135
|
+
summary:
|
|
136
|
+
visitor && cards.length > 0
|
|
137
|
+
? { finished: states.filter((s) => s === 'finished').length, total: cards.length, started: states.filter((s) => s === 'started').length }
|
|
138
|
+
: null,
|
|
139
|
+
signIn: visitor ? null : signInHref(astro.url.pathname),
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Classroom · Grid (board D1): the organization's courses as cards, three
|
|
3
|
+
// across on a wide screen, two on a tablet, one on a phone, each with this
|
|
4
|
+
// visitor's place in it (classroom.ts). The default layout; it draws `grid`
|
|
5
|
+
// and any layout the kit has no file for.
|
|
6
|
+
import type { Section } from '@backgold/content'
|
|
7
|
+
import Courses from './Courses.astro'
|
|
8
|
+
import { classroomOf } from './classroom'
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
section: Section
|
|
12
|
+
variant?: string
|
|
13
|
+
/** Where the courses come from: the section's rows (a page), or `GET /courses` (the courses list page). */
|
|
14
|
+
from?: 'rows' | 'read'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { section, from } = Astro.props
|
|
18
|
+
const classroom = await classroomOf(section, Astro, from)
|
|
19
|
+
---
|
|
20
|
+
<Courses section={section} classroom={classroom} layout="grid" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Classroom · List: the same courses as rows held to the content width, the
|
|
3
|
+
// cover at the left and the words, the bar or what it takes to watch beside
|
|
4
|
+
// it; on a phone each row is a card again (classroom.ts).
|
|
5
|
+
import type { ComponentProps } from 'astro/types'
|
|
6
|
+
import type Default from './index.astro'
|
|
7
|
+
import Courses from './Courses.astro'
|
|
8
|
+
import { classroomOf } from './classroom'
|
|
9
|
+
|
|
10
|
+
type Props = ComponentProps<typeof Default>
|
|
11
|
+
|
|
12
|
+
const { section, from } = Astro.props
|
|
13
|
+
const classroom = await classroomOf(section, Astro, from)
|
|
14
|
+
---
|
|
15
|
+
<Courses section={section} classroom={classroom} layout="list" />
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// A Collection's rows as its library, shelves, outline and feature layouts
|
|
2
|
+
// draw them: each entry's title, its page on this site, its summary, its
|
|
3
|
+
// picture, its first term (the one a library's chips and a shelf group by),
|
|
4
|
+
// its publish date and its authors' names, in the order the bake listed
|
|
5
|
+
// them. The "See all" link to the type's index reads "See all <plural>" as
|
|
6
|
+
// BackGold's own Collection block words it, and only while there are entries
|
|
7
|
+
// to see.
|
|
8
|
+
|
|
9
|
+
import type { Section } from '@backgold/content'
|
|
10
|
+
import { safeHref, safeSrc } from '@backgold/astro/server'
|
|
11
|
+
import { linkOf, nested, rows, type Link } from '../../../lib/section'
|
|
12
|
+
import { text } from '../../../lib/format'
|
|
13
|
+
|
|
14
|
+
export interface CollectionEntry {
|
|
15
|
+
title: string
|
|
16
|
+
href: string | null
|
|
17
|
+
summary: string | null
|
|
18
|
+
image: string | null
|
|
19
|
+
/** The entry's first term's label, or null when it has none. */
|
|
20
|
+
term: string | null
|
|
21
|
+
/** The row's `publish_at` as the bake sent it, or null. */
|
|
22
|
+
date: string | null
|
|
23
|
+
/** The authors' names, in the row's order; empty without one. */
|
|
24
|
+
authors: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function entriesOf(section: Section): CollectionEntry[] {
|
|
28
|
+
return rows(section).flatMap((row) => {
|
|
29
|
+
const title = text(row.title)
|
|
30
|
+
if (!title) return []
|
|
31
|
+
const [first] = nested(row, 'terms')
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
title,
|
|
35
|
+
href: safeHref(row.url, { anchors: true }),
|
|
36
|
+
summary: text(row.summary),
|
|
37
|
+
image: safeSrc(row.image_url),
|
|
38
|
+
term: text(first?.label)?.trim() ?? null,
|
|
39
|
+
date: text(row.publish_at),
|
|
40
|
+
authors: nested(row, 'authors').map((a) => text(a.name)).filter((n): n is string => n !== null),
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The distinct first terms, in the order they first appear. */
|
|
47
|
+
export function termsOf(entries: CollectionEntry[]): string[] {
|
|
48
|
+
return [...new Set(entries.map((e) => e.term).filter((t): t is string => t !== null))]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The type's plural name ("Courses"), or null when the bake gave none. */
|
|
52
|
+
export function pluralOf(section: Section): string | null {
|
|
53
|
+
return text(section.copy.pluralLabel)?.trim() ?? null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** "See all courses", to the type's index; none without entries, a label or a safe address. */
|
|
57
|
+
export function seeAllOf(section: Section, entries: CollectionEntry[]): Link[] {
|
|
58
|
+
const plural = pluralOf(section)
|
|
59
|
+
const href = section.links?.[0]?.url
|
|
60
|
+
const link = entries.length > 0 && plural ? linkOf(`See all ${plural.toLowerCase()}`, href) : null
|
|
61
|
+
return link ? [link] : []
|
|
62
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Collection · Lead story (A12, "Lead story", beside Cards and List): the
|
|
3
|
+
// heading with the "See all" link to the type's index at the right, then the
|
|
4
|
+
// first entry large, with its picture at 16:10, its first term as an accent
|
|
5
|
+
// chip, its title (the link to its page), its summary and its byline ("By A
|
|
6
|
+
// and B · Oct 2"), and the rest as a list beside it, each with its first
|
|
7
|
+
// term, title, date and a small square picture. Every row the bake sent is
|
|
8
|
+
// drawn, in its order; a single entry stands alone at a reading width. With
|
|
9
|
+
// no entries the heading stands over "Nothing here yet.", as the Cards
|
|
10
|
+
// layout says it; with neither, nothing is drawn.
|
|
11
|
+
import type { ComponentProps } from 'astro/types'
|
|
12
|
+
import type Default from './index.astro'
|
|
13
|
+
import Band from '../Band.astro'
|
|
14
|
+
import SectionHead from '../SectionHead.astro'
|
|
15
|
+
import { entriesOf, seeAllOf } from './entries'
|
|
16
|
+
import { formatShortDay, listOf, text } from '../../../lib/format'
|
|
17
|
+
|
|
18
|
+
type Props = ComponentProps<typeof Default>
|
|
19
|
+
|
|
20
|
+
const { section } = Astro.props
|
|
21
|
+
const heading = text(section.copy.heading)
|
|
22
|
+
const entries = entriesOf(section).map((entry) => ({
|
|
23
|
+
...entry,
|
|
24
|
+
shortDay: formatShortDay(entry.date),
|
|
25
|
+
byline: entry.authors.length > 0 ? `By ${listOf(entry.authors)}` : null,
|
|
26
|
+
}))
|
|
27
|
+
const [lead, ...rest] = entries
|
|
28
|
+
const Title = heading ? 'h3' : 'h2'
|
|
29
|
+
---
|
|
30
|
+
{(heading || lead) && (
|
|
31
|
+
<Band section={section} class="entries entries-feature">
|
|
32
|
+
<SectionHead kicker={null} heading={heading} more={seeAllOf(section, entries)} />
|
|
33
|
+
{lead ? (
|
|
34
|
+
<div class:list={['lead', { 'lead-alone': rest.length === 0 }]}>
|
|
35
|
+
<article class="lead-story">
|
|
36
|
+
{lead.image && <img class="lead-cover" src={lead.image} alt="" loading="lazy" decoding="async" />}
|
|
37
|
+
{lead.term && <p class="lead-chips"><span class="chip chip-accent">{lead.term}</span></p>}
|
|
38
|
+
<Title class="lead-title">{lead.href ? <a href={lead.href}>{lead.title}</a> : lead.title}</Title>
|
|
39
|
+
{lead.summary && <p class="lead-summary">{lead.summary}</p>}
|
|
40
|
+
{(lead.byline || lead.shortDay) && (
|
|
41
|
+
<p class="lead-byline">
|
|
42
|
+
{lead.byline}
|
|
43
|
+
{lead.byline && lead.shortDay && ' · '}
|
|
44
|
+
{lead.shortDay && <time datetime={lead.date}>{lead.shortDay}</time>}
|
|
45
|
+
</p>
|
|
46
|
+
)}
|
|
47
|
+
</article>
|
|
48
|
+
{rest.length > 0 && (
|
|
49
|
+
<ul class="lead-rest" role="list">
|
|
50
|
+
{rest.map((entry) => (
|
|
51
|
+
<li class:list={['lead-item', { 'lead-item-pictured': entry.image }]}>
|
|
52
|
+
<div>
|
|
53
|
+
{entry.term && <p class="lead-chips"><span class="chip">{entry.term}</span></p>}
|
|
54
|
+
<Title class="lead-item-title">{entry.href ? <a href={entry.href}>{entry.title}</a> : entry.title}</Title>
|
|
55
|
+
{entry.shortDay && <p class="lead-byline"><time datetime={entry.date}>{entry.shortDay}</time></p>}
|
|
56
|
+
</div>
|
|
57
|
+
{entry.image && <img class="lead-thumb" src={entry.image} alt="" loading="lazy" decoding="async" />}
|
|
58
|
+
</li>
|
|
59
|
+
))}
|
|
60
|
+
</ul>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
) : (
|
|
64
|
+
<p class="empty">Nothing here yet.</p>
|
|
65
|
+
)}
|
|
66
|
+
</Band>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.lead {
|
|
71
|
+
display: grid;
|
|
72
|
+
gap: 2rem;
|
|
73
|
+
}
|
|
74
|
+
.lead-story > *,
|
|
75
|
+
.lead-item p,
|
|
76
|
+
.lead-item .lead-item-title {
|
|
77
|
+
margin: 0;
|
|
78
|
+
}
|
|
79
|
+
.lead-chips .chip {
|
|
80
|
+
max-width: 100%;
|
|
81
|
+
white-space: normal;
|
|
82
|
+
overflow-wrap: anywhere;
|
|
83
|
+
}
|
|
84
|
+
/* The accent's own ink on its tint sits near 4:1 at this size; a fifth of
|
|
85
|
+
the band's ink carries it past 4.5:1 in both modes. */
|
|
86
|
+
.lead-chips .chip-accent {
|
|
87
|
+
color: color-mix(in srgb, var(--accent) 80%, var(--ink));
|
|
88
|
+
}
|
|
89
|
+
.lead-story .lead-cover {
|
|
90
|
+
display: block;
|
|
91
|
+
width: 100%;
|
|
92
|
+
aspect-ratio: 16 / 10;
|
|
93
|
+
object-fit: cover;
|
|
94
|
+
border-radius: var(--radius-card);
|
|
95
|
+
margin-bottom: 1.125rem;
|
|
96
|
+
}
|
|
97
|
+
.lead-story .lead-title {
|
|
98
|
+
margin: 0.75rem 0 0.625rem;
|
|
99
|
+
font-size: clamp(1.625rem, 1.2rem + 1.3vw, 2.125rem);
|
|
100
|
+
font-weight: 800;
|
|
101
|
+
line-height: 1.1;
|
|
102
|
+
overflow-wrap: anywhere;
|
|
103
|
+
}
|
|
104
|
+
.lead-story .lead-title:first-child,
|
|
105
|
+
.lead-story .lead-cover + .lead-title {
|
|
106
|
+
margin-top: 0;
|
|
107
|
+
}
|
|
108
|
+
.lead-title a,
|
|
109
|
+
.lead-item-title a {
|
|
110
|
+
color: var(--ink);
|
|
111
|
+
text-decoration: none;
|
|
112
|
+
}
|
|
113
|
+
.lead-title a:hover,
|
|
114
|
+
.lead-item-title a:hover {
|
|
115
|
+
text-decoration: underline;
|
|
116
|
+
}
|
|
117
|
+
.lead-story .lead-summary {
|
|
118
|
+
color: var(--muted);
|
|
119
|
+
font-size: 1.0625rem;
|
|
120
|
+
max-width: var(--measure);
|
|
121
|
+
}
|
|
122
|
+
.lead-byline {
|
|
123
|
+
margin-top: 0.25rem;
|
|
124
|
+
color: var(--muted);
|
|
125
|
+
font-size: var(--text-sm);
|
|
126
|
+
}
|
|
127
|
+
.lead-story .lead-byline {
|
|
128
|
+
margin-top: 0.875rem;
|
|
129
|
+
}
|
|
130
|
+
.lead-rest {
|
|
131
|
+
display: grid;
|
|
132
|
+
align-content: start;
|
|
133
|
+
margin: 0;
|
|
134
|
+
padding: 0;
|
|
135
|
+
list-style: none;
|
|
136
|
+
}
|
|
137
|
+
.lead-item {
|
|
138
|
+
display: grid;
|
|
139
|
+
gap: 1rem;
|
|
140
|
+
padding: 1.125rem 0;
|
|
141
|
+
border-top: 1px solid var(--line);
|
|
142
|
+
}
|
|
143
|
+
.lead-item-pictured {
|
|
144
|
+
grid-template-columns: minmax(0, 1fr) 5.5rem;
|
|
145
|
+
}
|
|
146
|
+
.lead-item:first-child {
|
|
147
|
+
border-top: 0;
|
|
148
|
+
padding-top: 0;
|
|
149
|
+
}
|
|
150
|
+
.lead-item .lead-item-title {
|
|
151
|
+
margin-top: 0.375rem;
|
|
152
|
+
font-size: 1.1875rem;
|
|
153
|
+
font-weight: 600;
|
|
154
|
+
line-height: 1.25;
|
|
155
|
+
overflow-wrap: anywhere;
|
|
156
|
+
}
|
|
157
|
+
.lead-item .lead-item-title:first-child {
|
|
158
|
+
margin-top: 0;
|
|
159
|
+
}
|
|
160
|
+
.lead-thumb {
|
|
161
|
+
display: block;
|
|
162
|
+
width: 100%;
|
|
163
|
+
aspect-ratio: 1;
|
|
164
|
+
object-fit: cover;
|
|
165
|
+
border-radius: var(--radius);
|
|
166
|
+
}
|
|
167
|
+
@media (min-width: 52rem) {
|
|
168
|
+
.lead {
|
|
169
|
+
grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
|
|
170
|
+
gap: 2.25rem;
|
|
171
|
+
}
|
|
172
|
+
.lead-alone {
|
|
173
|
+
grid-template-columns: minmax(0, 1fr);
|
|
174
|
+
max-width: 48rem;
|
|
175
|
+
}
|
|
176
|
+
.lead-item-pictured {
|
|
177
|
+
grid-template-columns: minmax(0, 1fr) 6.875rem;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Collection: entries the organization picked, as cards. `variant` is the
|
|
3
|
+
// layout chosen in BackGold ('list' stacks them; anything else is a grid).
|
|
4
|
+
import type { Section } from '@backgold/content'
|
|
5
|
+
import Band from '../Band.astro'
|
|
6
|
+
import EntryCard from '../../EntryCard.astro'
|
|
7
|
+
import { nested, rows, type Card } from '../../../lib/section'
|
|
8
|
+
import { listOf, text } from '../../../lib/format'
|
|
9
|
+
import { safeHref, safeSrc } from '@backgold/astro/server'
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
section: Section
|
|
13
|
+
variant?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { section } = Astro.props
|
|
17
|
+
const heading = text(section.copy.heading)
|
|
18
|
+
const cards: Card[] = rows(section).flatMap((row) => {
|
|
19
|
+
const title = text(row.title)
|
|
20
|
+
if (!title) return []
|
|
21
|
+
const image = safeSrc(row.image_url)
|
|
22
|
+
const authors = nested(row, 'authors').map((a) => text(a.name)).filter((n): n is string => n !== null)
|
|
23
|
+
const terms = nested(row, 'terms').map((t) => text(t.label)).filter((n): n is string => n !== null)
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
title,
|
|
27
|
+
href: safeHref(row.url, { anchors: true }),
|
|
28
|
+
summary: text(row.summary),
|
|
29
|
+
image: image ? { url: image, alt: '' } : null,
|
|
30
|
+
category: terms[0] ?? null,
|
|
31
|
+
date: text(row.publish_at),
|
|
32
|
+
meta: authors.length > 0 ? `By ${listOf(authors)}` : null,
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
---
|
|
37
|
+
<Band section={section} class="entries">
|
|
38
|
+
{heading && <h2>{heading}</h2>}
|
|
39
|
+
{cards.length > 0 ? (
|
|
40
|
+
<div class:list={['grid', section.variant === 'list' ? 'grid-1' : 'grid-3']}>
|
|
41
|
+
{cards.map((card) => <EntryCard card={card} level={heading ? 3 : 2} />)}
|
|
42
|
+
</div>
|
|
43
|
+
) : (
|
|
44
|
+
<p class="empty">Nothing here yet.</p>
|
|
45
|
+
)}
|
|
46
|
+
</Band>
|