@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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/chunk-KOB36GSF.js +62 -0
- package/dist/constants-DvTNj4JI.d-Batjcj3Z.d.ts +38 -0
- package/dist/content-api-CYeY0vU8.d.ts +849 -0
- package/dist/contract/content-api-examples.d.ts +58 -0
- package/dist/contract/content-api-examples.js +783 -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 +252 -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 +54 -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 +90 -0
- package/src/components/sections/About/index.astro +57 -0
- package/src/components/sections/About/left.astro +54 -0
- package/src/components/sections/About/letter.astro +108 -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 +119 -0
- package/src/components/sections/ContentPost/player.astro +254 -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 +170 -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 +96 -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/dates.astro +149 -0
- package/src/components/sections/VoterTools/index.astro +228 -0
- package/src/components/sections/VoterTools/polling.astro +141 -0
- package/src/components/sections/VoterTools/voter-tools.ts +70 -0
- package/src/components/sections/index.ts +370 -0
- package/src/components/sections/modules/Headed.astro +39 -0
- package/src/components/sections/modules/ModuleFrame.astro +179 -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 +64 -0
- package/src/layouts/Site.astro +371 -0
- package/src/lib/academy.ts +146 -0
- package/src/lib/brand.ts +534 -0
- package/src/lib/chrome.ts +119 -0
- package/src/lib/donate-frame.ts +64 -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 +54 -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 +94 -0
- package/src/lib/shifts.ts +186 -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 +286 -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/routes/volunteer.astro +37 -0
- package/src/styles/entries.css +784 -0
- package/src/styles/site.css +1839 -0
- package/src/template.ts +182 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Every address on the site. resolveRoute reads what the path is from
|
|
3
|
+
// BackGold (a page, a type's list, an entry, an author, a term, a feed), so
|
|
4
|
+
// a content type the organization adds gets its pages with no change here.
|
|
5
|
+
// Redirects were already answered by the middleware.
|
|
6
|
+
//
|
|
7
|
+
// An entry is drawn by its type's entry layout and a list (a type's list, or
|
|
8
|
+
// a term's) by its type's list layout, as the template's template.json
|
|
9
|
+
// `entryLayouts` names them (src/components/entries); a type it does not name, and the
|
|
10
|
+
// news list (the blog types' shared list at the organization's blog base,
|
|
11
|
+
// `/news` for one made since the address became its own, `/blog` for one that
|
|
12
|
+
// kept it), use the post layouts. A list shows
|
|
13
|
+
// one page of up to 50 entries: `?cursor=` asks for a later one, and the
|
|
14
|
+
// layout draws "Older" on to the next page and "Newest" back to the first
|
|
15
|
+
// (the api names no previous page, so there is no "Newer").
|
|
16
|
+
//
|
|
17
|
+
// The news list opens with its intro when a published page sits at its
|
|
18
|
+
// address (resolveRoute's `intro`; the starter's `news` page, board A4): that
|
|
19
|
+
// page's sections, its Hero's headline the one <h1>, above the list. Such a
|
|
20
|
+
// page is the list's opening, never a page of its own.
|
|
21
|
+
//
|
|
22
|
+
// The news list and its terms' lists carry a search box that sends `?q=` to
|
|
23
|
+
// the news list. There a search of 2 to 80 characters lists the matching
|
|
24
|
+
// posts (the Content API's `?q=`, at most 20 a type) in place of the list,
|
|
25
|
+
// with no pager; anything else under `q` shows the list. A response to a
|
|
26
|
+
// request with `q` is never stored: the edge cache keys a list by its cursor
|
|
27
|
+
// alone, so a stored search would answer the bare list's address. Neither is
|
|
28
|
+
// a response with a calendar's `?month=`, nor a page with a calendar section
|
|
29
|
+
// at all: the month it shows and its today move with the clock.
|
|
30
|
+
//
|
|
31
|
+
// A page that draws a Donate frame (a section or an area item of type Donate)
|
|
32
|
+
// names the donate query names its frame copies (READS_QUERY_HEADER,
|
|
33
|
+
// lib/donate-frame.ts), so the edge cache never answers `?amount=25` with
|
|
34
|
+
// the bare page's copy, and a request that carries one is never stored.
|
|
35
|
+
//
|
|
36
|
+
// `/events/<type>` is the events page with its Agenda and Calendar sections
|
|
37
|
+
// narrowed to that type (the Agenda's rows read from the Content API's `GET
|
|
38
|
+
// /events?type=`, src/lib/events.ts; the Calendar reads its month by type
|
|
39
|
+
// itself), when the path is not already a page or an entry; a type with no upcoming event, or
|
|
40
|
+
// one that does not exist, is a 404; it answers `X-BackGold-Page` with the
|
|
41
|
+
// events page's id (drawnInstead). Any other `/events/<slug>` that is not
|
|
42
|
+
// a page or an entry is that event's own page (the template's `eventPage`,
|
|
43
|
+
// else src/components/EventPage.astro), read from `GET /events/<slug>`; a slug the api has no event for is a 404. A
|
|
44
|
+
// type's tab wins over an event slugged like the type while the type has an
|
|
45
|
+
// upcoming event. `/events.ics` is every upcoming event as one calendar file
|
|
46
|
+
// and `/events/<slug>.ics` one event's (src/lib/events.ts).
|
|
47
|
+
//
|
|
48
|
+
// A lesson, `/<courses base>/<course>/<lesson>`, is the video read through
|
|
49
|
+
// its course (resolveRoute's `lesson`): drawn by the template's `course:lesson`
|
|
50
|
+
// entry layout (lessonLayoutFor; the kit's Lesson player when the template
|
|
51
|
+
// registers none), given the lesson as `entry` and the api's whole answer
|
|
52
|
+
// (the course, the lessons either side) as `lesson`. The course's list and its own page are the
|
|
53
|
+
// course type's list and entry layouts. Every read here is made for the
|
|
54
|
+
// signed-in visitor when there is one (`locals.backgold.visitorReads`), so
|
|
55
|
+
// their locks open; their pages are never cached (the middleware).
|
|
56
|
+
//
|
|
57
|
+
// A page passes itself to the layout as `{ id, takes_donations }`, so the
|
|
58
|
+
// menus apply each link's Shows on rule; every other route passes null. A
|
|
59
|
+
// page, an entry, a list, a term and an event pass their areas to the layout
|
|
60
|
+
// (Top banner and Above the footer). A page, an entry, a list and a term
|
|
61
|
+
// draw their Sidebar beside the main column when it has an item (under it on
|
|
62
|
+
// a phone); with none they are one column. A page that opens with a Hero
|
|
63
|
+
// puts the Hero over both columns, so the Sidebar starts under it, beside
|
|
64
|
+
// what follows (board C5). An event has no column beside it: its Sidebar
|
|
65
|
+
// items draw under the event, full width (board C6's "More chances").
|
|
66
|
+
import type { Areas } from '@backgold/content'
|
|
67
|
+
import { Area } from '@backgold/astro/components'
|
|
68
|
+
import { READS_QUERY_HEADER, areaEntriesOf, atomFeed, drawnInstead, jsonLdFor, pagerOf, relFor, resolveRoute, safeHref, safeSrc, type MenuPage, type Resolved } from '@backgold/astro/server'
|
|
69
|
+
import Site from '../layouts/Site.astro'
|
|
70
|
+
import EntryCard from '../components/EntryCard.astro'
|
|
71
|
+
import EventPage from '../components/EventPage.astro'
|
|
72
|
+
import NotFound from '../components/NotFound.astro'
|
|
73
|
+
import PageSections from '../components/PageSections.astro'
|
|
74
|
+
import { entryLayoutFor, lessonLayoutFor, listLayoutFor } from '../components/entries'
|
|
75
|
+
import type { ListLayoutProps } from '../components/entries/props'
|
|
76
|
+
import { basePath, filterOf, listName, searchNews, searchQuery } from '../lib/entries'
|
|
77
|
+
import { EVENTS_CALENDAR_PATH, MONTH_PARAM, calendarSlugOf, drawsCalendar, eventCalendar, eventPage, eventsCalendar, typedEventsPage } from '../lib/events'
|
|
78
|
+
import { entryCard, leadsWithHero } from '../lib/section'
|
|
79
|
+
import { DONATE_READS_QUERY, carriesDonateQuery, drawsDonateFrame } from '../lib/donate-frame'
|
|
80
|
+
import { markReading } from '../lib/reading'
|
|
81
|
+
import { COURSE_TYPE_KEY, lessonSignInTitle } from '../lib/academy'
|
|
82
|
+
import template from 'virtual:backgold-template'
|
|
83
|
+
|
|
84
|
+
const { sections } = template
|
|
85
|
+
// Every component this request draws reads the template here (ModuleFrame's frame options, LeadingHero's sections), areas and event pages included.
|
|
86
|
+
Astro.locals.template = template
|
|
87
|
+
/** One event's page and the 404's content: the template's own when it draws them, else the kit's. */
|
|
88
|
+
const EventLayout = template.eventPage ?? EventPage
|
|
89
|
+
const NotFoundLayout = template.notFound ?? NotFound
|
|
90
|
+
|
|
91
|
+
const bg = Astro.locals.backgold
|
|
92
|
+
if (bg.setup !== null) return new Response(null, { status: 503 })
|
|
93
|
+
|
|
94
|
+
const { client, site, siteUrl, visitorReads } = bg
|
|
95
|
+
const siteName = site.name ?? site.domain
|
|
96
|
+
const pathname = Astro.url.pathname
|
|
97
|
+
// `/events.ics` is every upcoming event as one calendar file (the events
|
|
98
|
+
// list's "Add every event to your calendar").
|
|
99
|
+
if (pathname === EVENTS_CALENDAR_PATH) {
|
|
100
|
+
const file = await eventsCalendar(client, siteUrl, `${siteName} events`)
|
|
101
|
+
if (!file) return new Response('Not found', { status: 404 })
|
|
102
|
+
return new Response(file, {
|
|
103
|
+
headers: { 'Content-Type': 'text/calendar; charset=utf-8', 'Content-Disposition': 'attachment; filename="events.ics"' },
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
// `/events/<slug>.ics` is the event's calendar file (its page's Add to calendar).
|
|
107
|
+
const calendarSlug = calendarSlugOf(pathname)
|
|
108
|
+
if (calendarSlug !== null) {
|
|
109
|
+
const found = await eventPage(client, `/events/${encodeURIComponent(calendarSlug)}`)
|
|
110
|
+
const file = found ? eventCalendar(found.event, new URL(`/events/${encodeURIComponent(found.event.slug)}`, siteUrl).toString(), new URL(siteUrl).host) : null
|
|
111
|
+
if (!file) return new Response('Not found', { status: 404 })
|
|
112
|
+
return new Response(file, {
|
|
113
|
+
headers: { 'Content-Type': 'text/calendar; charset=utf-8', 'Content-Disposition': `attachment; filename="${found!.event.slug}.ics"` },
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
// The URL, not just the path: a list's `?cursor=` asks for a later page.
|
|
117
|
+
let resolved: Resolved = await resolveRoute(client, Astro.url, visitorReads)
|
|
118
|
+
const typed = resolved.kind === 'not_found' ? await typedEventsPage(client, Astro.request, pathname) : null
|
|
119
|
+
if (typed) {
|
|
120
|
+
resolved = { kind: 'page', page: typed.page }
|
|
121
|
+
drawnInstead(resolved)
|
|
122
|
+
}
|
|
123
|
+
const event = resolved.kind === 'not_found' ? await eventPage(client, pathname) : null
|
|
124
|
+
const rawQuery = Astro.url.searchParams.get('q')
|
|
125
|
+
const calendar = Astro.url.searchParams.has(MONTH_PARAM) || (resolved.kind === 'page' && resolved.page.sections.some(drawsCalendar))
|
|
126
|
+
if (rawQuery !== null || calendar) Astro.response.headers.set('Cache-Control', 'no-store')
|
|
127
|
+
|
|
128
|
+
if (resolved.kind === 'feed') {
|
|
129
|
+
return new Response(await atomFeed(client, siteUrl, resolved.type), {
|
|
130
|
+
headers: { 'Content-Type': 'application/atom+xml; charset=utf-8' },
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
if (resolved.kind === 'not_found' && !event) Astro.response.status = 404
|
|
134
|
+
|
|
135
|
+
let head: { title?: string; description?: string; image?: string; canonicalPath: string; noindex?: boolean; jsonLd?: object[] }
|
|
136
|
+
switch (resolved.kind) {
|
|
137
|
+
case 'page': {
|
|
138
|
+
const { page, sections } = resolved.page
|
|
139
|
+
const firstImage = sections.flatMap((s) => Object.values(s.media ?? {})).map((m) => safeSrc(m.url)).find((u) => u !== null)
|
|
140
|
+
const title = page.meta.title ?? page.title ?? undefined
|
|
141
|
+
head = {
|
|
142
|
+
title: typed && title ? `${typed.type.label} · ${title}` : title,
|
|
143
|
+
description: page.meta.description ?? undefined,
|
|
144
|
+
image: safeSrc(page.meta.image_url) ?? firstImage ?? undefined,
|
|
145
|
+
canonicalPath: typed ? pathname : page.url,
|
|
146
|
+
jsonLd: jsonLdFor({ site, siteUrl, kind: 'page', page }),
|
|
147
|
+
}
|
|
148
|
+
break
|
|
149
|
+
}
|
|
150
|
+
case 'index':
|
|
151
|
+
head = {
|
|
152
|
+
title: `${listName(resolved.type, resolved.base, resolved.intro)} · ${siteName}`,
|
|
153
|
+
canonicalPath: pathname,
|
|
154
|
+
jsonLd: jsonLdFor({ site, siteUrl, kind: 'index', type: resolved.type, base: resolved.base, intro: resolved.intro }),
|
|
155
|
+
}
|
|
156
|
+
break
|
|
157
|
+
case 'entry': {
|
|
158
|
+
const { entry, type } = resolved
|
|
159
|
+
head = {
|
|
160
|
+
title: entry.title,
|
|
161
|
+
description: entry.summary ?? undefined,
|
|
162
|
+
image: entry.hero ? (safeSrc(entry.hero.url) ?? undefined) : undefined,
|
|
163
|
+
canonicalPath: entry.url ?? pathname,
|
|
164
|
+
jsonLd: jsonLdFor({ site, siteUrl, kind: 'entry', type, entry }),
|
|
165
|
+
}
|
|
166
|
+
break
|
|
167
|
+
}
|
|
168
|
+
case 'lesson': {
|
|
169
|
+
const { lesson, course } = resolved.lesson
|
|
170
|
+
head = {
|
|
171
|
+
title: `${lesson.title} · ${course.title}`,
|
|
172
|
+
description: lesson.summary ?? undefined,
|
|
173
|
+
image: lesson.hero ? (safeSrc(lesson.hero.url) ?? undefined) : undefined,
|
|
174
|
+
canonicalPath: pathname,
|
|
175
|
+
}
|
|
176
|
+
break
|
|
177
|
+
}
|
|
178
|
+
case 'author':
|
|
179
|
+
head = {
|
|
180
|
+
title: `${resolved.author.display_name} · ${siteName}`,
|
|
181
|
+
description: resolved.author.bio ?? undefined,
|
|
182
|
+
canonicalPath: pathname,
|
|
183
|
+
jsonLd: jsonLdFor({ site, siteUrl, kind: 'author', author: resolved.author }),
|
|
184
|
+
}
|
|
185
|
+
break
|
|
186
|
+
case 'term':
|
|
187
|
+
head = {
|
|
188
|
+
title: `${resolved.term.label} · ${siteName}`,
|
|
189
|
+
canonicalPath: pathname,
|
|
190
|
+
jsonLd: jsonLdFor({ site, siteUrl, kind: 'term', type: resolved.type, base: resolved.base, taxonomy: resolved.taxonomy, term: resolved.term }),
|
|
191
|
+
}
|
|
192
|
+
break
|
|
193
|
+
default:
|
|
194
|
+
head = event
|
|
195
|
+
? { title: `${event.event.title} · ${siteName}`, image: safeSrc(event.event.image_url) ?? undefined, canonicalPath: pathname }
|
|
196
|
+
: { title: `Page not found · ${siteName}`, canonicalPath: pathname, noindex: true }
|
|
197
|
+
}
|
|
198
|
+
const menuPage: MenuPage | null =
|
|
199
|
+
resolved.kind === 'page' ? { id: resolved.page.page.id, takes_donations: resolved.page.page.takes_donations } : null
|
|
200
|
+
const areas: Areas | null =
|
|
201
|
+
resolved.kind === 'page'
|
|
202
|
+
? resolved.page.areas
|
|
203
|
+
: resolved.kind === 'entry' || resolved.kind === 'index' || resolved.kind === 'term' || resolved.kind === 'lesson'
|
|
204
|
+
? resolved.areas
|
|
205
|
+
: event?.areas ?? null
|
|
206
|
+
if (drawsDonateFrame(resolved.kind === 'page' ? resolved.page.sections : [], areas)) {
|
|
207
|
+
Astro.response.headers.set(READS_QUERY_HEADER, DONATE_READS_QUERY)
|
|
208
|
+
if (carriesDonateQuery(Astro.url.searchParams)) Astro.response.headers.set('Cache-Control', 'no-store')
|
|
209
|
+
}
|
|
210
|
+
// The sections in an entry's areas leave out the entry being read (lib/reading.ts).
|
|
211
|
+
if (resolved.kind === 'entry') markReading(Astro.locals, resolved.entry.id)
|
|
212
|
+
if (resolved.kind === 'lesson') markReading(Astro.locals, resolved.lesson.lesson.id)
|
|
213
|
+
const sidebar = resolved.kind !== 'author' && resolved.kind !== 'not_found' && areaEntriesOf(areas, 'sidebar').length > 0
|
|
214
|
+
const heroOverSplit = sidebar && resolved.kind === 'page' && leadsWithHero(resolved.page.sections)
|
|
215
|
+
const eventMore = event !== null && areaEntriesOf(event.areas, 'sidebar').length > 0
|
|
216
|
+
|
|
217
|
+
// A list, or a term's list: its layout and what it is given. The filter comes
|
|
218
|
+
// from the type's whole first page, so every term with an entry on it stays
|
|
219
|
+
// offered while one is chosen, on every later page and beside a search.
|
|
220
|
+
let list: { Layout: ReturnType<typeof listLayoutFor>; props: ListLayoutProps } | null = null
|
|
221
|
+
if (resolved.kind === 'index' || resolved.kind === 'term') {
|
|
222
|
+
const key = resolved.type === 'blog' ? 'post' : resolved.type.key
|
|
223
|
+
const base = basePath(resolved.base)
|
|
224
|
+
const whole = resolved.kind === 'index' && resolved.cursor === null ? resolved : await resolveRoute(client, base, visitorReads)
|
|
225
|
+
const news = resolved.type === 'blog'
|
|
226
|
+
const q = news && resolved.kind === 'index' ? searchQuery(rawQuery) : null
|
|
227
|
+
list = {
|
|
228
|
+
Layout: listLayoutFor(template, key),
|
|
229
|
+
props: {
|
|
230
|
+
template,
|
|
231
|
+
type: resolved.type,
|
|
232
|
+
base: resolved.base,
|
|
233
|
+
entries: q === null ? resolved.entries : await searchNews(client, q),
|
|
234
|
+
pager: q === null ? pagerOf(resolved, pathname) : { newest: null, older: null },
|
|
235
|
+
filter: whole?.kind === 'index' ? filterOf(whole.entries) : null,
|
|
236
|
+
term: resolved.kind === 'term' ? { taxonomy: resolved.taxonomy, term: resolved.term } : null,
|
|
237
|
+
search: news ? { action: base, q } : null,
|
|
238
|
+
intro: resolved.kind === 'index' ? resolved.intro : null,
|
|
239
|
+
areas,
|
|
240
|
+
},
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const ListLayout = list?.Layout ?? null
|
|
244
|
+
const EntryLayout = resolved.kind === 'entry' ? entryLayoutFor(template, resolved.entry.type) : null
|
|
245
|
+
const LessonLayout = resolved.kind === 'lesson' ? lessonLayoutFor(template) : null
|
|
246
|
+
/** What the header's Sign in names to the portal's door: a lesson, or a course's title on the course's page. */
|
|
247
|
+
const signInTitle =
|
|
248
|
+
resolved.kind === 'lesson'
|
|
249
|
+
? lessonSignInTitle(resolved.lesson)
|
|
250
|
+
: resolved.kind === 'entry' && resolved.type.key === COURSE_TYPE_KEY
|
|
251
|
+
? resolved.entry.title
|
|
252
|
+
: null
|
|
253
|
+
const avatar = resolved.kind === 'author' ? safeSrc(resolved.author.avatar_url) : null
|
|
254
|
+
const authorLink = resolved.kind === 'author' ? safeHref(resolved.author.link_url) : null
|
|
255
|
+
---
|
|
256
|
+
<Site {...head} template={template} page={menuPage} areas={areas} signInTitle={signInTitle}>
|
|
257
|
+
{resolved.kind === 'author' && (
|
|
258
|
+
<div class="listing">
|
|
259
|
+
<header class="page-header author">
|
|
260
|
+
{avatar && <img class="author-avatar" src={avatar} alt="" />}
|
|
261
|
+
<h1>{resolved.author.display_name}</h1>
|
|
262
|
+
{resolved.author.bio && <p class="lede">{resolved.author.bio}</p>}
|
|
263
|
+
{authorLink && <p><a href={authorLink} rel={relFor(authorLink)}>More about {resolved.author.display_name}</a></p>}
|
|
264
|
+
</header>
|
|
265
|
+
{resolved.entries.length > 0 && (
|
|
266
|
+
<div class="grid grid-3">{resolved.entries.map((entry) => <EntryCard card={entryCard(entry)} />)}</div>
|
|
267
|
+
)}
|
|
268
|
+
</div>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
{resolved.kind === 'not_found' && (event ? <EventLayout event={event.event} /> : <NotFoundLayout />)}
|
|
272
|
+
{eventMore && event && <Area name="sidebar" areas={event.areas} components={sections} class="event-more" />}
|
|
273
|
+
|
|
274
|
+
{heroOverSplit && resolved.kind === 'page' && <PageSections template={template} page={resolved.page} siteName={siteName} only="lead" />}
|
|
275
|
+
{resolved.kind !== 'author' && resolved.kind !== 'not_found' && (
|
|
276
|
+
<div class:list={['layout', sidebar && 'layout-split']}>
|
|
277
|
+
<div class="layout-main">
|
|
278
|
+
{resolved.kind === 'page' && <PageSections template={template} page={resolved.page} siteName={siteName} only={heroOverSplit ? 'rest' : undefined} />}
|
|
279
|
+
{resolved.kind === 'entry' && EntryLayout && <EntryLayout entry={resolved.entry} type={resolved.type} areas={areas} />}
|
|
280
|
+
{resolved.kind === 'lesson' && LessonLayout && <LessonLayout entry={resolved.lesson.lesson} type={undefined} areas={areas} lesson={resolved.lesson} />}
|
|
281
|
+
{ListLayout && list && <ListLayout {...list.props} />}
|
|
282
|
+
</div>
|
|
283
|
+
{sidebar && <div class="layout-rail"><Area name="sidebar" areas={areas} components={sections} class="rail" /></div>}
|
|
284
|
+
</div>
|
|
285
|
+
)}
|
|
286
|
+
</Site>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
// `/form/<slug>`: the address of an organization's standalone form that its
|
|
3
|
+
// flyers print. On a hosted site the api serves the form there and at
|
|
4
|
+
// `/<slug>`; on a template site the Content API lists the form as the page
|
|
5
|
+
// at `<slug>`, so this route answers a 301 to `/<slug>` (its query string
|
|
6
|
+
// kept) whenever the site has a page at that slug, read through the content
|
|
7
|
+
// client (GET /pages/<slug>). A slug with no page is the 404: the template's
|
|
8
|
+
// `notFound`, else the kit's NotFound. `/form` alone and deeper addresses
|
|
9
|
+
// (`/form/<slug>/…`) are not this route's.
|
|
10
|
+
// The kit's integration serves it, for the template its `template` option
|
|
11
|
+
// names (`virtual:backgold-template`).
|
|
12
|
+
import Site from '../layouts/Site.astro'
|
|
13
|
+
import NotFound from '../components/NotFound.astro'
|
|
14
|
+
import template from 'virtual:backgold-template'
|
|
15
|
+
|
|
16
|
+
Astro.locals.template = template
|
|
17
|
+
const bg = Astro.locals.backgold
|
|
18
|
+
if (bg.setup !== null) return new Response(null, { status: 503 })
|
|
19
|
+
|
|
20
|
+
const { client, site } = bg
|
|
21
|
+
const siteName = site.name ?? site.domain
|
|
22
|
+
const slug = Astro.params.slug ?? ''
|
|
23
|
+
const page = slug ? await client.page(slug) : null
|
|
24
|
+
if (page) return Astro.redirect(`/${encodeURIComponent(slug)}${Astro.url.search}`, 301)
|
|
25
|
+
Astro.response.status = 404
|
|
26
|
+
const NotFoundLayout = template.notFound ?? NotFound
|
|
27
|
+
---
|
|
28
|
+
<Site template={template} title={`Page not found · ${siteName}`} canonicalPath={Astro.url.pathname} noindex page={null}>
|
|
29
|
+
<NotFoundLayout />
|
|
30
|
+
</Site>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
// `/live`: the organization's YouTube stream (GET /live, lib/stream.ts),
|
|
3
|
+
// drawn by the template's `livePage` (the kit's components/live/LivePage
|
|
4
|
+
// when it has none) under the site's header and footer: the player and the
|
|
5
|
+
// live chat while it is live, the still and when it starts while it is
|
|
6
|
+
// upcoming, "Not live right now" with the three newest videos while the
|
|
7
|
+
// channel is off; never a blank page. The newest videos are the video type's
|
|
8
|
+
// list (GET /entries/video), whose areas the page draws (the Top banner and
|
|
9
|
+
// Above the footer, the sign-up band there): an organization with no video
|
|
10
|
+
// type has neither. The edge cache keys this page on the stream as it keys
|
|
11
|
+
// every page (@backgold/astro's liveVariant), and a browser may keep it for
|
|
12
|
+
// the stream's own minute.
|
|
13
|
+
// The kit's integration serves it, for the template its `template` option
|
|
14
|
+
// names (`virtual:backgold-template`).
|
|
15
|
+
import { appearanceOf } from '../lib/brand'
|
|
16
|
+
import { listOf } from '../lib/entries'
|
|
17
|
+
import { LIVE_PATH, liveHead, liveStream, streamView } from '../lib/stream'
|
|
18
|
+
import Site from '../layouts/Site.astro'
|
|
19
|
+
import LivePage from '../components/live/LivePage.astro'
|
|
20
|
+
import template from 'virtual:backgold-template'
|
|
21
|
+
|
|
22
|
+
/** How many of the newest videos the page lists while the channel is off. */
|
|
23
|
+
const NEWEST = 3
|
|
24
|
+
|
|
25
|
+
Astro.locals.template = template
|
|
26
|
+
const bg = Astro.locals.backgold
|
|
27
|
+
if (bg.setup !== null) return new Response(null, { status: 503 })
|
|
28
|
+
|
|
29
|
+
const { client, site } = bg
|
|
30
|
+
const siteName = site.name ?? site.domain
|
|
31
|
+
const [stream, newest, types] = await Promise.all([
|
|
32
|
+
liveStream(bg),
|
|
33
|
+
client.entries('video', { limit: NEWEST }).catch(() => null),
|
|
34
|
+
client.types().catch(() => null),
|
|
35
|
+
])
|
|
36
|
+
/** A site that opens dark gets the chat in YouTube's dark look: pinned dark, or auto on a template that opens dark. */
|
|
37
|
+
const appearance = appearanceOf(site.style)
|
|
38
|
+
const dark = appearance === 'dark' || (appearance === 'auto' && template.defaultAppearance === 'dark')
|
|
39
|
+
const view = stream ? streamView(stream, new URL(bg.siteUrl).hostname, dark) : null
|
|
40
|
+
const channel = view?.channelTitle ?? (bg.orgName || siteName)
|
|
41
|
+
const videoList = listOf(types?.types.find((t) => t.key === 'video'))
|
|
42
|
+
const areas = newest?.areas ?? null
|
|
43
|
+
const head = liveHead(view, channel, siteName)
|
|
44
|
+
const LiveLayout = template.livePage ?? LivePage
|
|
45
|
+
Astro.response.headers.set('Cache-Control', 'public, max-age=60')
|
|
46
|
+
---
|
|
47
|
+
<Site template={template} title={head.title} description={head.description} canonicalPath={LIVE_PATH} page={null} areas={areas}>
|
|
48
|
+
<LiveLayout stream={view} videos={(newest?.entries ?? []).slice(0, NEWEST)} videoList={videoList} channel={channel} areas={areas} />
|
|
49
|
+
</Site>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Astro's own 404 page, for anything the catch-all page does not answer.
|
|
3
|
+
// The catch-all renders the same content for an unknown address: the
|
|
4
|
+
// template's `notFound`, else the kit's NotFound.
|
|
5
|
+
// The kit's integration serves it at /404, for the template its `template`
|
|
6
|
+
// option names (`virtual:backgold-template`).
|
|
7
|
+
import Site from '../layouts/Site.astro'
|
|
8
|
+
import NotFound from '../components/NotFound.astro'
|
|
9
|
+
import template from 'virtual:backgold-template'
|
|
10
|
+
|
|
11
|
+
Astro.response.status = 404
|
|
12
|
+
const bg = Astro.locals.backgold
|
|
13
|
+
const siteName = bg.setup === null ? (bg.site.name ?? bg.site.domain) : ''
|
|
14
|
+
const NotFoundLayout = template.notFound ?? NotFound
|
|
15
|
+
---
|
|
16
|
+
<Site template={template} title={`Page not found · ${siteName}`} canonicalPath={Astro.url.pathname} noindex page={null}>
|
|
17
|
+
<NotFoundLayout />
|
|
18
|
+
</Site>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
// BackGold's "Preview on your site" link: /preview?bg_preview=<token>&path=<path>.
|
|
3
|
+
// On BackGold's own deploys (the BACKGOLD_API binding) the draft is read
|
|
4
|
+
// first-party through the binding as the site, with no key: the composer's
|
|
5
|
+
// frame needs nothing set up. A copy deployed with the Deploy button reads it
|
|
6
|
+
// with BACKGOLD_SECRET_KEY (it never reaches the page), and without one
|
|
7
|
+
// answers 503. Either way it is rendered with the same layout, menus, areas
|
|
8
|
+
// and components as the published site, under a "Draft · not published"
|
|
9
|
+
// bar, and each section carries the marker the BackGold editor scrolls to.
|
|
10
|
+
// Never cached, never indexed. A bad or expired link answers 400. The kit's
|
|
11
|
+
// integration serves this page at /preview, for the template its `template`
|
|
12
|
+
// option names (`virtual:backgold-template`).
|
|
13
|
+
import { PREVIEW_HEADERS, areaEntriesOf, loadPreview, type MenuPage } from '@backgold/astro/server'
|
|
14
|
+
import { Area, PreviewBar } from '@backgold/astro/components'
|
|
15
|
+
import Site from '../layouts/Site.astro'
|
|
16
|
+
import { entryLayoutFor } from '../components/entries'
|
|
17
|
+
import PageSections from '../components/PageSections.astro'
|
|
18
|
+
import { leadsWithHero } from '../lib/section'
|
|
19
|
+
import template from 'virtual:backgold-template'
|
|
20
|
+
|
|
21
|
+
const { sections } = template
|
|
22
|
+
|
|
23
|
+
const result = await loadPreview(Astro.request)
|
|
24
|
+
if (!result.ok) return result.response
|
|
25
|
+
for (const [name, value] of Object.entries(PREVIEW_HEADERS)) Astro.response.headers.set(name, value)
|
|
26
|
+
|
|
27
|
+
const bg = Astro.locals.backgold
|
|
28
|
+
if (bg.setup !== null) return new Response(null, { status: 503, headers: PREVIEW_HEADERS })
|
|
29
|
+
// The site as it is right now, read beside the draft: the header and footer
|
|
30
|
+
// just saved in BackGold draw in this frame at once, and the menus read
|
|
31
|
+
// under the current version, rather than as the Worker's cache last knew
|
|
32
|
+
// them (it checks the version once a minute).
|
|
33
|
+
bg.site = result.site.site
|
|
34
|
+
bg.legal = result.site.legal
|
|
35
|
+
bg.version = result.site.version
|
|
36
|
+
await bg.client.setVersion(result.site.version)
|
|
37
|
+
const draft = result.preview
|
|
38
|
+
const siteName = bg.site.name ?? bg.site.domain
|
|
39
|
+
const type = 'entry' in draft ? (await bg.client.types()).types.find((t) => t.key === draft.entry.type) : undefined
|
|
40
|
+
const title = 'page' in draft ? (draft.page.title ?? siteName) : draft.entry.title
|
|
41
|
+
const menuPage: MenuPage | null = 'page' in draft ? { id: draft.page.id, takes_donations: draft.page.takes_donations } : null
|
|
42
|
+
const areas = draft.areas ?? null
|
|
43
|
+
const sidebar = areaEntriesOf(areas, 'sidebar').length > 0
|
|
44
|
+
// A page that opens with a Hero puts it over both columns, as the live route does.
|
|
45
|
+
const heroOverSplit = sidebar && 'page' in draft && leadsWithHero(draft.sections)
|
|
46
|
+
const EntryLayout = 'entry' in draft ? entryLayoutFor(template, draft.entry.type) : null
|
|
47
|
+
// The frames and the leading Hero read the template from here (ModuleFrame, LeadingHero).
|
|
48
|
+
Astro.locals.template = template
|
|
49
|
+
---
|
|
50
|
+
<Site template={template} title={`Preview: ${title}`} canonicalPath={result.path} noindex page={menuPage} areas={areas}>
|
|
51
|
+
<PreviewBar />
|
|
52
|
+
{heroOverSplit && 'page' in draft && <PageSections template={template} page={draft} siteName={siteName} only="lead" />}
|
|
53
|
+
<div class:list={['layout', sidebar && 'layout-split']}>
|
|
54
|
+
<div class="layout-main">
|
|
55
|
+
{'page' in draft && <PageSections template={template} page={draft} siteName={siteName} only={heroOverSplit ? 'rest' : undefined} />}
|
|
56
|
+
{EntryLayout && 'entry' in draft && <EntryLayout entry={draft.entry} type={type} areas={areas} />}
|
|
57
|
+
</div>
|
|
58
|
+
{sidebar && <div class="layout-rail"><Area name="sidebar" areas={areas} components={sections} class="rail" /></div>}
|
|
59
|
+
</div>
|
|
60
|
+
</Site>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Shown for every page until the site is connected to BackGold (the
|
|
3
|
+
// middleware sends each request here while BACKGOLD_SITE_KEY is missing or
|
|
4
|
+
// malformed; once it is set, this address is a 404). There is no BackGold
|
|
5
|
+
// data yet, so this page uses none: no layout, no menus, no brand.
|
|
6
|
+
//
|
|
7
|
+
// The kit's integration serves it at /backgold-setup. It imports the
|
|
8
|
+
// template's config (`virtual:backgold-template`) for its stylesheet alone:
|
|
9
|
+
// the template's src/styles/template.css, after the kit's site.css.
|
|
10
|
+
import { brandCss } from '../lib/brand'
|
|
11
|
+
import '../styles/site.css'
|
|
12
|
+
import 'virtual:backgold-template'
|
|
13
|
+
|
|
14
|
+
const HELP: Record<string, { what: string; where: string }> = {
|
|
15
|
+
BACKGOLD_SITE_KEY: {
|
|
16
|
+
what: 'The site’s publishable key. It starts with bg_site_pk_.',
|
|
17
|
+
where: 'In BackGold, open Sites, choose this site, then Developer. The key is under Keys, with a copy button.',
|
|
18
|
+
},
|
|
19
|
+
BACKGOLD_API_ORIGIN: {
|
|
20
|
+
what: 'Where BackGold’s Content API lives. It must be a web address starting with https://.',
|
|
21
|
+
where: 'Use https://api.backgold.com unless BackGold has told you otherwise.',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const missing = Astro.locals.backgold.setup?.missing ?? []
|
|
26
|
+
---
|
|
27
|
+
<!doctype html>
|
|
28
|
+
<html lang="en">
|
|
29
|
+
<head>
|
|
30
|
+
<meta charset="utf-8" />
|
|
31
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
32
|
+
<meta name="robots" content="noindex" />
|
|
33
|
+
<title>Connect this site to BackGold</title>
|
|
34
|
+
<style is:inline set:html={brandCss(null)}></style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<main id="main" class="setup">
|
|
38
|
+
<h1>Almost there: connect this site to BackGold</h1>
|
|
39
|
+
<p class="lede">The site is deployed, but it does not know which BackGold site to show yet.</p>
|
|
40
|
+
{missing.length > 0 && (
|
|
41
|
+
<>
|
|
42
|
+
<h2>{missing.length === 1 ? 'One setting needs a value' : 'These settings need a value'}</h2>
|
|
43
|
+
<ul class="setup-list" role="list">
|
|
44
|
+
{missing.map((name) => (
|
|
45
|
+
<li>
|
|
46
|
+
<p><code>{name}</code></p>
|
|
47
|
+
<p>{HELP[name]?.what ?? 'A setting the site needs.'}</p>
|
|
48
|
+
{HELP[name] && <p class="muted">{HELP[name].where}</p>}
|
|
49
|
+
</li>
|
|
50
|
+
))}
|
|
51
|
+
</ul>
|
|
52
|
+
</>
|
|
53
|
+
)}
|
|
54
|
+
<h2>Where to set it</h2>
|
|
55
|
+
<p>
|
|
56
|
+
In the Cloudflare dashboard, open Workers & Pages, choose this Worker, then Settings, then Variables and
|
|
57
|
+
Secrets. Running locally, put it in <code>wrangler.jsonc</code> under <code>vars</code>.
|
|
58
|
+
</p>
|
|
59
|
+
<p class="muted">This page goes away by itself once the setting is saved.</p>
|
|
60
|
+
</main>
|
|
61
|
+
</body>
|
|
62
|
+
</html>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
// `/volunteer/<slug>`: one open shift's page, the row of GET /shifts with
|
|
3
|
+
// that slug (lib/shifts.ts), drawn by the template's `volunteer:detail`
|
|
4
|
+
// (volunteerLayoutFor; the kit's components/volunteer/detail when it
|
|
5
|
+
// registers none) under the site's header and footer, with the areas of a
|
|
6
|
+
// page that holds events (GET /areas?holds=event); the Sidebar's items draw
|
|
7
|
+
// under the shift, full width, as under an event. A shift that belongs to a
|
|
8
|
+
// public event names it ("Part of"), by the event's title from GET
|
|
9
|
+
// /events/<slug>; an event the site cannot read leaves the line out. A slug
|
|
10
|
+
// the feed does not list (an ended shift, an unknown one, or an api with no
|
|
11
|
+
// feed) is the 404: the template's `notFound`, else the kit's NotFound.
|
|
12
|
+
// Deeper addresses (`/volunteer/<slug>/…`) are not this route's.
|
|
13
|
+
// The kit's integration serves it, for the template its `template` option
|
|
14
|
+
// names (`virtual:backgold-template`).
|
|
15
|
+
import { Area } from '@backgold/astro/components'
|
|
16
|
+
import { areaEntriesOf } from '@backgold/astro/server'
|
|
17
|
+
import Site from '../layouts/Site.astro'
|
|
18
|
+
import NotFound from '../components/NotFound.astro'
|
|
19
|
+
import { volunteerLayoutFor } from '../components/entries'
|
|
20
|
+
import { eventPage } from '../lib/events'
|
|
21
|
+
import { linkOf, type Link } from '../lib/section'
|
|
22
|
+
import { openShifts, shiftPath, volunteerAreas } from '../lib/shifts'
|
|
23
|
+
import template from 'virtual:backgold-template'
|
|
24
|
+
|
|
25
|
+
Astro.locals.template = template
|
|
26
|
+
const bg = Astro.locals.backgold
|
|
27
|
+
if (bg.setup !== null) return new Response(null, { status: 503 })
|
|
28
|
+
|
|
29
|
+
const { client, site } = bg
|
|
30
|
+
const siteName = site.name ?? site.domain
|
|
31
|
+
const slug = Astro.params.slug ?? ''
|
|
32
|
+
const [shifts, areas] = await Promise.all([openShifts(client), volunteerAreas(client)])
|
|
33
|
+
const shift = shifts?.find((s) => s.slug === slug) ?? null
|
|
34
|
+
if (!shift) Astro.response.status = 404
|
|
35
|
+
|
|
36
|
+
/** The public event the shift belongs to, by its title; null for a standalone shift or an event the site cannot read. */
|
|
37
|
+
async function partOfOf(): Promise<Link | null> {
|
|
38
|
+
if (!shift || shift.subject.kind !== 'event' || !shift.subject.slug) return null
|
|
39
|
+
const path = `/events/${encodeURIComponent(shift.subject.slug)}`
|
|
40
|
+
try {
|
|
41
|
+
const found = await eventPage(client, path)
|
|
42
|
+
return found ? linkOf(found.event.title, path) : null
|
|
43
|
+
} catch {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const partOf = await partOfOf()
|
|
48
|
+
const DetailLayout = volunteerLayoutFor(template, 'detail')
|
|
49
|
+
const NotFoundLayout = template.notFound ?? NotFound
|
|
50
|
+
const more = shift !== null && areaEntriesOf(areas, 'sidebar').length > 0
|
|
51
|
+
---
|
|
52
|
+
{shift ? (
|
|
53
|
+
<Site template={template} title={`${shift.title} · ${siteName}`} description={`A volunteer shift with ${siteName}.`} canonicalPath={shiftPath(shift.slug)} page={null} areas={areas}>
|
|
54
|
+
<DetailLayout shift={shift} partOf={partOf} siteName={siteName} />
|
|
55
|
+
{more && <Area name="sidebar" areas={areas} components={template.sections} class="event-more" />}
|
|
56
|
+
</Site>
|
|
57
|
+
) : (
|
|
58
|
+
<Site template={template} title={`Page not found · ${siteName}`} canonicalPath={Astro.url.pathname} noindex page={null}>
|
|
59
|
+
<NotFoundLayout />
|
|
60
|
+
</Site>
|
|
61
|
+
)}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
// `/volunteer`: the organization's open volunteer shifts (GET /shifts, every
|
|
3
|
+
// page of it up to 200, lib/shifts.ts), drawn by the template's
|
|
4
|
+
// `volunteer:list` (volunteerLayoutFor; the kit's components/volunteer/list
|
|
5
|
+
// when it registers none) under the site's header and footer, with the areas
|
|
6
|
+
// of a page that holds events (GET /areas?holds=event): the Top banner and
|
|
7
|
+
// Above the footer, and the Sidebar beside the list when it has an item
|
|
8
|
+
// (under it on a phone), as on any page. An api that serves no shift feed
|
|
9
|
+
// draws the layout's empty state. The page is cached by content version
|
|
10
|
+
// like every page; the counts are read again after load.
|
|
11
|
+
// The kit's integration serves it, for the template its `template` option
|
|
12
|
+
// names (`virtual:backgold-template`).
|
|
13
|
+
import { Area } from '@backgold/astro/components'
|
|
14
|
+
import { areaEntriesOf } from '@backgold/astro/server'
|
|
15
|
+
import Site from '../layouts/Site.astro'
|
|
16
|
+
import { volunteerLayoutFor } from '../components/entries'
|
|
17
|
+
import { VOLUNTEER_PATH, openShifts, volunteerAreas } from '../lib/shifts'
|
|
18
|
+
import template from 'virtual:backgold-template'
|
|
19
|
+
|
|
20
|
+
Astro.locals.template = template
|
|
21
|
+
const bg = Astro.locals.backgold
|
|
22
|
+
if (bg.setup !== null) return new Response(null, { status: 503 })
|
|
23
|
+
|
|
24
|
+
const { client, site } = bg
|
|
25
|
+
const siteName = site.name ?? site.domain
|
|
26
|
+
const [shifts, areas] = await Promise.all([openShifts(client), volunteerAreas(client)])
|
|
27
|
+
const ListLayout = volunteerLayoutFor(template, 'list')
|
|
28
|
+
const sidebar = areaEntriesOf(areas, 'sidebar').length > 0
|
|
29
|
+
---
|
|
30
|
+
<Site template={template} title={`Volunteer · ${siteName}`} description={`Open volunteer shifts with ${siteName}.`} canonicalPath={VOLUNTEER_PATH} page={null} areas={areas}>
|
|
31
|
+
<div class:list={['layout', sidebar && 'layout-split']}>
|
|
32
|
+
<div class="layout-main">
|
|
33
|
+
<ListLayout shifts={shifts ?? []} siteName={siteName} />
|
|
34
|
+
</div>
|
|
35
|
+
{sidebar && <div class="layout-rail"><Area name="sidebar" areas={areas} components={template.sections} class="rail" /></div>}
|
|
36
|
+
</div>
|
|
37
|
+
</Site>
|