@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,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Comparison, 'spectrum' layout (board 08, "Issue slider"): the section head
|
|
3
|
+
// and the body, a key to the marks, then a card per issue on the band's
|
|
4
|
+
// surface: the issue as its heading and a rail, drawn as the Progress meter
|
|
5
|
+
// is, with a mark for each side at its place from 0 (the left end, under
|
|
6
|
+
// which `leftLabel` sits) to 100 (the right end, `rightLabel`). Ours is a
|
|
7
|
+
// pill in the band's button colour above the rail, carrying our short label,
|
|
8
|
+
// over a dot on the rail at our exact place; each opponent is a small circle
|
|
9
|
+
// in the ink on the rail with the initial of their label, named in full in
|
|
10
|
+
// the key above the cards. A side with no
|
|
11
|
+
// place on an issue has no mark on its rail, and an issue no side has placed
|
|
12
|
+
// is not drawn.
|
|
13
|
+
//
|
|
14
|
+
// Marks closer than COLLIDE points apart would overlap on a phone, so a
|
|
15
|
+
// later side (in the order us, them, them2) within that distance of an
|
|
16
|
+
// earlier one is stacked: `data-stack` drops it below the rail, a step to
|
|
17
|
+
// the first level no nearby earlier mark holds, and draws it over the mark
|
|
18
|
+
// it meets, ringed in the surface colour so the two read apart; the rail
|
|
19
|
+
// grows by the steps it uses. The rail
|
|
20
|
+
// says every place in words for a screen reader. Nothing is drawn with
|
|
21
|
+
// neither a heading nor an issue.
|
|
22
|
+
import type { ComponentProps } from 'astro/types'
|
|
23
|
+
import type Default from './index.astro'
|
|
24
|
+
import Band from '../Band.astro'
|
|
25
|
+
import SectionHead from '../SectionHead.astro'
|
|
26
|
+
import Prose from '../../Prose.astro'
|
|
27
|
+
import { text } from '../../../lib/format'
|
|
28
|
+
import { linesOf, sidesOf, type Side } from './sides'
|
|
29
|
+
|
|
30
|
+
type Props = ComponentProps<typeof Default>
|
|
31
|
+
|
|
32
|
+
const COLLIDE = 10
|
|
33
|
+
|
|
34
|
+
const { section } = Astro.props
|
|
35
|
+
const kicker = text(section.copy.kicker)
|
|
36
|
+
const heading = text(section.copy.heading)
|
|
37
|
+
const leftLabel = text(section.copy.leftLabel)
|
|
38
|
+
const rightLabel = text(section.copy.rightLabel)
|
|
39
|
+
const all = linesOf(section)
|
|
40
|
+
const sides = sidesOf(section).filter((side) => all.some((line) => line.at[side.key] !== null))
|
|
41
|
+
const scale = leftLabel || rightLabel ? `from ${leftLabel ?? 'the left'} (0) to ${rightLabel ?? 'the right'} (100)` : 'from 0 to 100'
|
|
42
|
+
const issues = all.flatMap((line) => {
|
|
43
|
+
const marks: { side: Side; at: number; stack: number }[] = []
|
|
44
|
+
for (const side of sides) {
|
|
45
|
+
const at = line.at[side.key]
|
|
46
|
+
if (at === null) continue
|
|
47
|
+
const taken = marks.filter((m) => Math.abs(m.at - at) < COLLIDE).map((m) => m.stack)
|
|
48
|
+
let stack = 0
|
|
49
|
+
while (taken.includes(stack)) stack++
|
|
50
|
+
marks.push({ side, at, stack })
|
|
51
|
+
}
|
|
52
|
+
if (marks.length === 0) return []
|
|
53
|
+
const words = marks.map((m) => `${m.side.label} ${Math.round(m.at)}`).join(', ')
|
|
54
|
+
return [{ issue: line.issue, marks, depth: Math.max(...marks.map((m) => m.stack)), label: `Where each stands, ${scale}: ${words}.` }]
|
|
55
|
+
})
|
|
56
|
+
const ours = sides.find((side) => side.key === 'us')
|
|
57
|
+
---
|
|
58
|
+
{(heading || issues.length > 0) && (
|
|
59
|
+
<Band section={section} class="comparison comparison-spectrum">
|
|
60
|
+
<SectionHead kicker={kicker} heading={heading} more={[]} />
|
|
61
|
+
<Prose value={section.copy.body} class="lede" />
|
|
62
|
+
{issues.length > 0 && (
|
|
63
|
+
<>
|
|
64
|
+
<ul class="key" role="list" aria-label="Key">
|
|
65
|
+
{sides.map((side) => (
|
|
66
|
+
<li class="key-item">
|
|
67
|
+
{side.key === 'us' && side.short === side.label ? (
|
|
68
|
+
<span class="mark-pill">{side.label}</span>
|
|
69
|
+
) : (
|
|
70
|
+
<>
|
|
71
|
+
{side.key === 'us' ? <span class="mark-pill" aria-hidden="true">{side.short}</span> : <span class="mark-dot" aria-hidden="true">{side.initial}</span>}
|
|
72
|
+
<span>{side.label}</span>
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
</li>
|
|
76
|
+
))}
|
|
77
|
+
</ul>
|
|
78
|
+
<ul class="spectra" role="list">
|
|
79
|
+
{issues.map((item) => (
|
|
80
|
+
<li class="spectrum">
|
|
81
|
+
<h3 class="spectrum-issue">{item.issue}</h3>
|
|
82
|
+
<div class:list={['rail', ours && 'rail-has-us']} role="img" aria-label={item.label}>
|
|
83
|
+
<div class="rail-field" style={`--depth: ${item.depth}`}>
|
|
84
|
+
<span class="rail-track"></span>
|
|
85
|
+
{item.marks.map((m) =>
|
|
86
|
+
m.side.key === 'us' ? (
|
|
87
|
+
<>
|
|
88
|
+
<span class="mark-pill rail-pill" style={`--at: ${m.at}`}>{m.side.short}</span>
|
|
89
|
+
<span class="rail-pin" style={`--at: ${m.at}`}></span>
|
|
90
|
+
</>
|
|
91
|
+
) : (
|
|
92
|
+
<span class="mark-dot rail-dot" style={`--at: ${m.at}`} data-stack={m.stack}>
|
|
93
|
+
{m.side.initial}<span class="visually-hidden"> {m.side.label}</span>
|
|
94
|
+
</span>
|
|
95
|
+
),
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
{(leftLabel || rightLabel) && (
|
|
100
|
+
<p class="rail-ends" aria-hidden="true">
|
|
101
|
+
<span>{leftLabel}</span>
|
|
102
|
+
<span>{rightLabel}</span>
|
|
103
|
+
</p>
|
|
104
|
+
)}
|
|
105
|
+
</li>
|
|
106
|
+
))}
|
|
107
|
+
</ul>
|
|
108
|
+
</>
|
|
109
|
+
)}
|
|
110
|
+
</Band>
|
|
111
|
+
)}
|
|
112
|
+
|
|
113
|
+
<style>
|
|
114
|
+
/* The marks, in the key and on the rails. */
|
|
115
|
+
.mark-pill {
|
|
116
|
+
display: inline-flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
min-height: 1.75rem;
|
|
119
|
+
padding: 0 0.75rem;
|
|
120
|
+
border-radius: var(--pill);
|
|
121
|
+
background: var(--button);
|
|
122
|
+
color: var(--button-ink);
|
|
123
|
+
font-size: var(--text-sm);
|
|
124
|
+
font-weight: 700;
|
|
125
|
+
line-height: 1;
|
|
126
|
+
white-space: nowrap;
|
|
127
|
+
}
|
|
128
|
+
.mark-dot {
|
|
129
|
+
display: inline-grid;
|
|
130
|
+
place-items: center;
|
|
131
|
+
width: 1.75rem;
|
|
132
|
+
height: 1.75rem;
|
|
133
|
+
border-radius: 50%;
|
|
134
|
+
background: var(--ink);
|
|
135
|
+
color: var(--surface);
|
|
136
|
+
font-size: 0.6875rem;
|
|
137
|
+
font-weight: 800;
|
|
138
|
+
letter-spacing: 0.02em;
|
|
139
|
+
line-height: 1;
|
|
140
|
+
}
|
|
141
|
+
.key {
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-wrap: wrap;
|
|
144
|
+
gap: 0.625rem 1.5rem;
|
|
145
|
+
margin: 0 0 1.25rem;
|
|
146
|
+
padding: 0;
|
|
147
|
+
list-style: none;
|
|
148
|
+
font-size: var(--text-sm);
|
|
149
|
+
font-weight: 600;
|
|
150
|
+
}
|
|
151
|
+
.key-item {
|
|
152
|
+
display: inline-flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: 0.5rem;
|
|
155
|
+
}
|
|
156
|
+
.spectra {
|
|
157
|
+
display: grid;
|
|
158
|
+
gap: 0.75rem;
|
|
159
|
+
margin: 0;
|
|
160
|
+
padding: 0;
|
|
161
|
+
list-style: none;
|
|
162
|
+
}
|
|
163
|
+
.spectrum {
|
|
164
|
+
padding: 1.25rem 1.25rem 1rem;
|
|
165
|
+
border: 1px solid var(--line);
|
|
166
|
+
border-radius: var(--radius-card);
|
|
167
|
+
background: var(--surface);
|
|
168
|
+
}
|
|
169
|
+
.spectrum .spectrum-issue {
|
|
170
|
+
margin: 0 0 0.75rem;
|
|
171
|
+
font-size: var(--text-lg);
|
|
172
|
+
font-weight: 700;
|
|
173
|
+
}
|
|
174
|
+
/*
|
|
175
|
+
The rail: a field inset by half a circle on each side, so a mark at 0 or
|
|
176
|
+
100 sits on the track's end. The pill rides above the track and leans
|
|
177
|
+
with its place (translateX by the same share it sits along the field), so
|
|
178
|
+
it never runs past either end; the pin under it marks the exact place.
|
|
179
|
+
*/
|
|
180
|
+
.rail {
|
|
181
|
+
padding: 0 0.875rem;
|
|
182
|
+
}
|
|
183
|
+
.rail-field {
|
|
184
|
+
position: relative;
|
|
185
|
+
height: calc(2.5rem + var(--depth) * 1.375rem);
|
|
186
|
+
}
|
|
187
|
+
.rail-has-us .rail-field {
|
|
188
|
+
height: calc(4.25rem + var(--depth) * 1.375rem);
|
|
189
|
+
}
|
|
190
|
+
.rail-track {
|
|
191
|
+
position: absolute;
|
|
192
|
+
left: -0.875rem;
|
|
193
|
+
right: -0.875rem;
|
|
194
|
+
top: 1rem;
|
|
195
|
+
height: 0.75rem;
|
|
196
|
+
border-radius: var(--pill);
|
|
197
|
+
background: var(--line-strong);
|
|
198
|
+
}
|
|
199
|
+
.rail-has-us .rail-track {
|
|
200
|
+
top: 2.75rem;
|
|
201
|
+
}
|
|
202
|
+
.rail-pill {
|
|
203
|
+
position: absolute;
|
|
204
|
+
top: 0;
|
|
205
|
+
left: calc(var(--at) * 1%);
|
|
206
|
+
transform: translateX(calc(var(--at) * -1%));
|
|
207
|
+
z-index: 3;
|
|
208
|
+
}
|
|
209
|
+
.rail-pin {
|
|
210
|
+
position: absolute;
|
|
211
|
+
top: 2.6875rem;
|
|
212
|
+
left: calc(var(--at) * 1%);
|
|
213
|
+
width: 0.875rem;
|
|
214
|
+
height: 0.875rem;
|
|
215
|
+
transform: translateX(-50%);
|
|
216
|
+
z-index: 4;
|
|
217
|
+
border-radius: 50%;
|
|
218
|
+
background: var(--button);
|
|
219
|
+
box-shadow: 0 0 0 2px var(--surface);
|
|
220
|
+
}
|
|
221
|
+
.rail-pin::before {
|
|
222
|
+
content: '';
|
|
223
|
+
position: absolute;
|
|
224
|
+
left: calc(50% - 1px);
|
|
225
|
+
bottom: 100%;
|
|
226
|
+
width: 2px;
|
|
227
|
+
height: 0.9375rem;
|
|
228
|
+
background: var(--button);
|
|
229
|
+
}
|
|
230
|
+
.rail-dot {
|
|
231
|
+
position: absolute;
|
|
232
|
+
top: 0.5rem;
|
|
233
|
+
left: calc(var(--at) * 1%);
|
|
234
|
+
transform: translateX(-50%);
|
|
235
|
+
z-index: 2;
|
|
236
|
+
box-shadow: 0 0 0 2px var(--surface);
|
|
237
|
+
}
|
|
238
|
+
.rail-has-us .rail-dot {
|
|
239
|
+
top: 2.25rem;
|
|
240
|
+
}
|
|
241
|
+
/* A stacked mark drops a step below the one it meets and is drawn over it; the step clears the initial of the mark above. */
|
|
242
|
+
.rail-dot[data-stack='1'] {
|
|
243
|
+
transform: translate(-50%, 1.375rem);
|
|
244
|
+
z-index: 3;
|
|
245
|
+
}
|
|
246
|
+
.rail-dot[data-stack='2'] {
|
|
247
|
+
transform: translate(-50%, 2.75rem);
|
|
248
|
+
z-index: 3;
|
|
249
|
+
}
|
|
250
|
+
.rail-ends {
|
|
251
|
+
display: flex;
|
|
252
|
+
justify-content: space-between;
|
|
253
|
+
gap: 1rem;
|
|
254
|
+
margin: 0;
|
|
255
|
+
color: var(--muted);
|
|
256
|
+
font-size: var(--text-sm);
|
|
257
|
+
}
|
|
258
|
+
.rail-ends span:last-child {
|
|
259
|
+
text-align: right;
|
|
260
|
+
}
|
|
261
|
+
</style>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
// ContentPost · Banner (board A12, "Banner"): one piece as a wide banner
|
|
3
|
+
// across the band's column. The piece's hero fills it behind a scrim in the
|
|
4
|
+
// photo band's ground, deepest at the left where the words sit, and the
|
|
5
|
+
// words read in the photo band's inks: the section's heading as a kicker,
|
|
6
|
+
// the title (linking to the piece's page on this site, as the Card layout
|
|
7
|
+
// links it), the body's first paragraph as the line under it, the date, and
|
|
8
|
+
// one button to the piece. The row carries no summary, so the line is the
|
|
9
|
+
// body's first paragraph as plain text (lesson.ts dekOf), whole in the page
|
|
10
|
+
// and held to three lines here. The button's words follow what the piece's
|
|
11
|
+
// page plays: "Watch the video" for a video, "Listen to the episode" for
|
|
12
|
+
// audio, and by the piece's kind when it has no media ("Read the post" for
|
|
13
|
+
// an article). Without a hero the same banner sits on the photo band's solid
|
|
14
|
+
// ground; without a page to link to, the title is plain and there is no
|
|
15
|
+
// button. With no piece baked the section draws nothing, as the Card layout
|
|
16
|
+
// does.
|
|
17
|
+
import type { ComponentProps } from 'astro/types'
|
|
18
|
+
import type Default from './index.astro'
|
|
19
|
+
import { safeSrc } from '@backgold/astro/server'
|
|
20
|
+
import Band from '../Band.astro'
|
|
21
|
+
import { dekOf, lessonOf } from './lesson'
|
|
22
|
+
import { rows } from '../../../lib/section'
|
|
23
|
+
|
|
24
|
+
type Props = ComponentProps<typeof Default>
|
|
25
|
+
|
|
26
|
+
const { section } = Astro.props
|
|
27
|
+
const lesson = await lessonOf(section, Astro.locals.backgold)
|
|
28
|
+
const [row] = rows(section)
|
|
29
|
+
// The hero: the image a piece without media shows, a video's poster, a podcast's cover.
|
|
30
|
+
const picture = safeSrc(row?.image_url)
|
|
31
|
+
const dek = dekOf(section.copy.postHtml)
|
|
32
|
+
const plays = lesson?.media?.kind
|
|
33
|
+
const action =
|
|
34
|
+
plays === 'embed' || plays === 'video'
|
|
35
|
+
? 'Watch the video'
|
|
36
|
+
: plays === 'audio'
|
|
37
|
+
? 'Listen to the episode'
|
|
38
|
+
: row?.kind === 'vlog'
|
|
39
|
+
? 'Watch the video'
|
|
40
|
+
: row?.kind === 'podcast'
|
|
41
|
+
? 'Listen to the episode'
|
|
42
|
+
: 'Read the post'
|
|
43
|
+
---
|
|
44
|
+
{lesson && (
|
|
45
|
+
<Band section={section} class="featured featured-banner">
|
|
46
|
+
<div class:list={['cb', picture && 'cb-photo']}>
|
|
47
|
+
{picture && (
|
|
48
|
+
<>
|
|
49
|
+
<img class="cb-image" src={picture} alt="" loading="lazy" decoding="async" />
|
|
50
|
+
<div class="cb-scrim" aria-hidden="true"></div>
|
|
51
|
+
</>
|
|
52
|
+
)}
|
|
53
|
+
<div class="cb-words on-photo">
|
|
54
|
+
{lesson.kicker && <p class="kicker">{lesson.kicker}</p>}
|
|
55
|
+
<h2 class="cb-title featured-title">{lesson.href ? <a href={lesson.href}>{lesson.title}</a> : lesson.title}</h2>
|
|
56
|
+
{dek && <p class="cb-dek">{dek}</p>}
|
|
57
|
+
{lesson.day && lesson.date && <p class="fine cb-date"><time datetime={lesson.date}>{lesson.day}</time></p>}
|
|
58
|
+
{lesson.href && (
|
|
59
|
+
<p class="actions cb-actions"><a class="button" href={lesson.href}>{action}</a></p>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</Band>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
/* The banner: its own frame inside the band's column, on the photo band's ground. */
|
|
68
|
+
.cb {
|
|
69
|
+
position: relative;
|
|
70
|
+
isolation: isolate;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
min-height: 16rem;
|
|
75
|
+
border-radius: var(--radius-card);
|
|
76
|
+
background: var(--band-photo);
|
|
77
|
+
}
|
|
78
|
+
/* Without a picture a hairline keeps the banner's edge on a dark page, whose ground is near the photo band's. */
|
|
79
|
+
.cb:not(.cb-photo) {
|
|
80
|
+
box-shadow: inset 0 0 0 1px var(--band-photo-line);
|
|
81
|
+
}
|
|
82
|
+
.cb-image {
|
|
83
|
+
position: absolute;
|
|
84
|
+
inset: 0;
|
|
85
|
+
z-index: -2;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
max-width: none;
|
|
89
|
+
object-fit: cover;
|
|
90
|
+
}
|
|
91
|
+
/* Until the banner is wide the words take most of its width, so the scrim is deep across it. */
|
|
92
|
+
.cb-scrim {
|
|
93
|
+
position: absolute;
|
|
94
|
+
inset: 0;
|
|
95
|
+
z-index: -1;
|
|
96
|
+
background: linear-gradient(
|
|
97
|
+
180deg,
|
|
98
|
+
color-mix(in srgb, var(--band-photo) 82%, transparent) 0%,
|
|
99
|
+
color-mix(in srgb, var(--band-photo) 90%, transparent) 100%
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
.cb-words {
|
|
103
|
+
width: 100%;
|
|
104
|
+
max-width: 36rem;
|
|
105
|
+
padding: clamp(1.75rem, 1.25rem + 2vw, 3rem) clamp(1.25rem, 0.75rem + 2.5vw, 3rem);
|
|
106
|
+
}
|
|
107
|
+
.cb-words > * {
|
|
108
|
+
margin: 0;
|
|
109
|
+
}
|
|
110
|
+
.cb-words .kicker {
|
|
111
|
+
margin-bottom: 0.75rem;
|
|
112
|
+
}
|
|
113
|
+
.cb-title {
|
|
114
|
+
font-size: calc(var(--h2) * 0.85);
|
|
115
|
+
line-height: 1.08;
|
|
116
|
+
letter-spacing: -0.015em;
|
|
117
|
+
overflow-wrap: anywhere;
|
|
118
|
+
}
|
|
119
|
+
.cb-words .cb-dek {
|
|
120
|
+
display: -webkit-box;
|
|
121
|
+
-webkit-box-orient: vertical;
|
|
122
|
+
-webkit-line-clamp: 3;
|
|
123
|
+
line-clamp: 3;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
margin-top: 0.875rem;
|
|
126
|
+
color: color-mix(in srgb, var(--ink) 92%, transparent);
|
|
127
|
+
font-size: var(--text-lg);
|
|
128
|
+
line-height: 1.5;
|
|
129
|
+
}
|
|
130
|
+
.cb-words .cb-date {
|
|
131
|
+
margin-top: 0.625rem;
|
|
132
|
+
}
|
|
133
|
+
.cb-words .cb-actions {
|
|
134
|
+
margin-top: 1.5rem;
|
|
135
|
+
}
|
|
136
|
+
@media (min-width: 48rem) {
|
|
137
|
+
.cb {
|
|
138
|
+
min-height: 20rem;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/* On a wide banner the words keep to its left part: the scrim stays deep under them and lets the picture through at the right. */
|
|
142
|
+
@media (min-width: 64rem) {
|
|
143
|
+
.cb-scrim {
|
|
144
|
+
background: linear-gradient(
|
|
145
|
+
90deg,
|
|
146
|
+
color-mix(in srgb, var(--band-photo) 88%, transparent) 0%,
|
|
147
|
+
color-mix(in srgb, var(--band-photo) 82%, transparent) 62%,
|
|
148
|
+
color-mix(in srgb, var(--band-photo) 25%, transparent) 100%
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
// ContentPost: one featured post, linked to its page on this site. The blog
|
|
3
|
+
// types live under the organization's blog base, so the link is
|
|
4
|
+
// /<blog base>/<slug> (`/news/<slug>`, or `/blog/<slug>` on an organization
|
|
5
|
+
// that kept that address).
|
|
6
|
+
import type { Section } from '@backgold/content'
|
|
7
|
+
import { blogBaseOf } from '@backgold/astro/server'
|
|
8
|
+
import Band from '../Band.astro'
|
|
9
|
+
import { basePath } from '../../../lib/entries'
|
|
10
|
+
import { rows } from '../../../lib/section'
|
|
11
|
+
import { formatDay, text } from '../../../lib/format'
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
section: Section
|
|
15
|
+
variant?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { section } = Astro.props
|
|
19
|
+
const heading = text(section.copy.heading)
|
|
20
|
+
const [row] = rows(section)
|
|
21
|
+
const title = text(row?.title)
|
|
22
|
+
const slug = text(row?.slug)
|
|
23
|
+
const bg = Astro.locals.backgold
|
|
24
|
+
const base = slug && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(slug) && bg.setup === null ? blogBaseOf((await bg.client.types()).types) : null
|
|
25
|
+
const href = base ? `${basePath(base)}/${slug}` : null
|
|
26
|
+
const date = text(row?.date)
|
|
27
|
+
const day = formatDay(date)
|
|
28
|
+
---
|
|
29
|
+
{title && (
|
|
30
|
+
<Band section={section} class="featured">
|
|
31
|
+
{heading && <p class="kicker">{heading}</p>}
|
|
32
|
+
<h2 class="featured-title">{href ? <a href={href}>{title}</a> : title}</h2>
|
|
33
|
+
{day && date && <p class="fine"><time datetime={date}>{day}</time></p>}
|
|
34
|
+
</Band>
|
|
35
|
+
)}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// A ContentPost as its player and theater layouts draw it: the piece's title
|
|
2
|
+
// and its page on this site (/<blog base>/<slug>, as the Card layout links
|
|
3
|
+
// it), its date, its media, its notes and the section's links.
|
|
4
|
+
//
|
|
5
|
+
// The media is what the entry page's own layouts play: a video row's YouTube
|
|
6
|
+
// or Vimeo address in that player (lib/entries.ts playerOf), any other video
|
|
7
|
+
// in the browser's player with the hero as its poster, an audio row's file in
|
|
8
|
+
// the browser's audio controls beside the hero, and the hero alone when the
|
|
9
|
+
// piece has no media. The notes are the bake's render of the entry body
|
|
10
|
+
// (headings, lists, links and paragraphs), reduced to the entry editor's
|
|
11
|
+
// allowlist again here before the page emits them (notesOf).
|
|
12
|
+
|
|
13
|
+
import type { Section } from '@backgold/content'
|
|
14
|
+
import { blogBaseOf, sanitizeRichText, safeSrc } from '@backgold/astro/server'
|
|
15
|
+
import { basePath, playerOf } from '../../../lib/entries'
|
|
16
|
+
import { links, rows, type Link } from '../../../lib/section'
|
|
17
|
+
import { formatDay, text } from '../../../lib/format'
|
|
18
|
+
|
|
19
|
+
export type LessonMedia =
|
|
20
|
+
| { kind: 'embed'; src: string }
|
|
21
|
+
| { kind: 'video'; src: string; poster: string | null }
|
|
22
|
+
| { kind: 'audio'; src: string; cover: string | null }
|
|
23
|
+
| { kind: 'image'; src: string }
|
|
24
|
+
|
|
25
|
+
export interface Lesson {
|
|
26
|
+
/** The section's own heading, drawn as a kicker over the title. */
|
|
27
|
+
kicker: string | null
|
|
28
|
+
title: string
|
|
29
|
+
href: string | null
|
|
30
|
+
/** The row's own date, for `<time datetime>`, with `day` its words; both null without a date. */
|
|
31
|
+
date: string | null
|
|
32
|
+
day: string | null
|
|
33
|
+
media: LessonMedia | null
|
|
34
|
+
/** The notes as sanitized HTML, or null when the piece has no body. */
|
|
35
|
+
notes: string | null
|
|
36
|
+
notesLabel: string
|
|
37
|
+
links: Link[]
|
|
38
|
+
/** The links' heading, or null when the operator left it blank. */
|
|
39
|
+
linksHeading: string | null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function mediaOf(row: Record<string, unknown>): LessonMedia | null {
|
|
43
|
+
const src = safeSrc(row.media_url)
|
|
44
|
+
const image = safeSrc(row.image_url)
|
|
45
|
+
if (src && row.media_kind === 'video') {
|
|
46
|
+
const player = playerOf(src)
|
|
47
|
+
return player ? { kind: 'embed', src: player } : { kind: 'video', src, poster: image }
|
|
48
|
+
}
|
|
49
|
+
if (src && row.media_kind === 'audio') return { kind: 'audio', src, cover: image }
|
|
50
|
+
return image ? { kind: 'image', src: image } : null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const escapeText = (value: string) => value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The body as HTML a page can emit: the bake's HTML through the allowlist, or
|
|
57
|
+
* plain text as paragraphs (a blank line between them). The Prose layout
|
|
58
|
+
* emits it as it is, under the section's title.
|
|
59
|
+
*/
|
|
60
|
+
export function bodyOf(value: unknown): string {
|
|
61
|
+
const raw = text(value)?.trim()
|
|
62
|
+
if (!raw) return ''
|
|
63
|
+
return raw.startsWith('<')
|
|
64
|
+
? sanitizeRichText(raw)
|
|
65
|
+
: raw
|
|
66
|
+
.split(/\n{2,}/)
|
|
67
|
+
.map((p) => p.trim())
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.map((p) => `<p>${escapeText(p)}</p>`)
|
|
70
|
+
.join('')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The notes: the body (bodyOf) with its headings moved down two levels
|
|
75
|
+
* (h2 → h4, h3 → h5) to sit under the section's title (h2) and the notes'
|
|
76
|
+
* own heading (h3).
|
|
77
|
+
*/
|
|
78
|
+
function notesOf(value: unknown): string {
|
|
79
|
+
return bodyOf(value).replace(/<(\/?)h([23])>/g, (_, slash: string, level: string) => `<${slash}h${Number(level) + 2}>`)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The body's first paragraph as plain text, whole (the layout clamps it), or
|
|
84
|
+
* null when the body has none: the notes' first `<p>` that holds words, with
|
|
85
|
+
* its markup gone and the sanitizer's three entities read back (a paragraph
|
|
86
|
+
* holding only a picture is passed over). A plain-text body's first
|
|
87
|
+
* paragraph is the text before its first blank line.
|
|
88
|
+
*/
|
|
89
|
+
export function dekOf(value: unknown): string | null {
|
|
90
|
+
for (const [, inner = ''] of notesOf(value).matchAll(/<p>([\s\S]*?)<\/p>/g)) {
|
|
91
|
+
const dek = inner
|
|
92
|
+
.replace(/<br>/g, ' ')
|
|
93
|
+
.replace(/<[^>]*>/g, '')
|
|
94
|
+
.replace(/</g, '<')
|
|
95
|
+
.replace(/>/g, '>')
|
|
96
|
+
.replace(/&/g, '&')
|
|
97
|
+
.replace(/\s+/g, ' ')
|
|
98
|
+
.trim()
|
|
99
|
+
if (dek) return dek
|
|
100
|
+
}
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The section's piece, or null when the bake found none (the section then draws nothing, as the Card layout does). */
|
|
105
|
+
export async function lessonOf(section: Section, bg: App.Locals['backgold']): Promise<Lesson | null> {
|
|
106
|
+
const [row] = rows(section)
|
|
107
|
+
const title = text(row?.title)
|
|
108
|
+
if (!row || !title) return null
|
|
109
|
+
const slug = text(row.slug)
|
|
110
|
+
const base = slug && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(slug) && bg.setup === null ? blogBaseOf((await bg.client.types()).types) : null
|
|
111
|
+
const date = text(row.date)
|
|
112
|
+
const day = formatDay(date)
|
|
113
|
+
const notes = notesOf(section.copy.postHtml)
|
|
114
|
+
return {
|
|
115
|
+
kicker: text(section.copy.heading),
|
|
116
|
+
title,
|
|
117
|
+
href: base ? `${basePath(base)}/${slug}` : null,
|
|
118
|
+
date: day ? date : null,
|
|
119
|
+
day,
|
|
120
|
+
media: mediaOf(row),
|
|
121
|
+
notes: notes.trim() ? notes : null,
|
|
122
|
+
notesLabel: text(section.copy.notesLabel)?.trim() ?? 'Notes',
|
|
123
|
+
links: links(section),
|
|
124
|
+
linksHeading: text(section.copy.linksHeading)?.trim() ?? null,
|
|
125
|
+
}
|
|
126
|
+
}
|