diff --git a/package.json b/package.json index d489d50..0d09a5f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "siteforge", "private": true, - "version": "2.9.0", + "version": "2.9.1", "type": "module", "scripts": { "dev": "vite", diff --git a/server/helpers.js b/server/helpers.js index 24e1780..e8dd7b0 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -141,6 +141,7 @@ export function sanitizeFeaturedLinks(value) { return { id: typeof item.id === 'string' && item.id.trim() ? item.id.trim() : randomUUID(), + lane: item.lane === 'second' || item.lane === 'general' ? item.lane : 'primary', title: typeof item.title === 'string' ? item.title.trim().slice(0, 140) : '', episodeNumber: typeof item.episodeNumber === 'string' ? item.episodeNumber.trim().slice(0, 20) : '', summary: typeof item.summary === 'string' ? item.summary.trim().slice(0, 600) : '', diff --git a/server/routes/admin-content.js b/server/routes/admin-content.js index 82b57e8..05f6ff9 100644 --- a/server/routes/admin-content.js +++ b/server/routes/admin-content.js @@ -82,6 +82,12 @@ function applySeriesTransition(content, sched, lane = 'primary') { const newSeason = Number.isInteger(sched.newSeason) ? sched.newSeason : undefined const newStudySlug = typeof sched.newStudySlug === 'string' ? sched.newStudySlug.trim().toLowerCase() : '' + // Highlights for the ending series move onto its Finished Book; the other lane's and general ones stay. + const allHighlights = Array.isArray(content.podcastFeaturedLinks) ? content.podcastFeaturedLinks : [] + const isThisLane = link => (link.lane === 'second' ? 'second' : link.lane === 'general' ? 'general' : 'primary') === lane + const endingHighlights = current.title.trim() ? allHighlights.filter(isThisLane) : [] + const keptHighlights = current.title.trim() ? allHighlights.filter(link => !isThisLane(link)) : allHighlights + const archivedBook = current.title.trim() ? { id: Date.now().toString(36), @@ -90,6 +96,7 @@ function applySeriesTransition(content, sched, lane = 'primary') { imageUrl: current.imageUrl, season: current.season ?? ((newSeason ?? 2) - 1 || 1), ...(current.studySlug ? { studySlug: current.studySlug } : {}), + ...(endingHighlights.length > 0 ? { highlights: endingHighlights.map(({ lane: _lane, ...link }) => link) } : {}), } : null @@ -126,10 +133,6 @@ function applySeriesTransition(content, sched, lane = 'primary') { return study }) - const hasOtherLane = lane === 'second' - ? Boolean(content.seriesTitle?.trim()) - : Boolean(content.secondSeries?.title?.trim()) - const lanePatch = lane === 'second' ? { secondSeries: { @@ -155,8 +158,7 @@ function applySeriesTransition(content, sched, lane = 'primary') { ...content, ...lanePatch, studies, - // Highlights belong to whatever is playing now; don't wipe them while the other lane is still running. - podcastFeaturedLinks: hasOtherLane ? content.podcastFeaturedLinks : [], + podcastFeaturedLinks: keptHighlights, finishedBooks: [...(Array.isArray(content.finishedBooks) ? content.finishedBooks : []), ...(archivedBook ? [archivedBook] : [])], ...patch, }) diff --git a/server/routes/public.js b/server/routes/public.js index 671e696..73e980e 100644 --- a/server/routes/public.js +++ b/server/routes/public.js @@ -102,7 +102,10 @@ export function register(app) { } } // Dynamic episode highlight URLs - const highlights = Array.isArray(state.cachedSiteContent?.podcastFeaturedLinks) ? state.cachedSiteContent.podcastFeaturedLinks : [] + const highlights = [ + ...(Array.isArray(state.cachedSiteContent?.podcastFeaturedLinks) ? state.cachedSiteContent.podcastFeaturedLinks : []), + ...(Array.isArray(state.cachedSiteContent?.finishedBooks) ? state.cachedSiteContent.finishedBooks.flatMap(book => (Array.isArray(book?.highlights) ? book.highlights : [])) : []), + ] for (const ep of highlights) { if (ep.id) urls.push(`${root}/episodes/${encodeURIComponent(ep.id)}`) } @@ -195,7 +198,10 @@ export function register(app) { app.get('/api/public/scripture-index', async (_req, res) => { const content = state.cachedSiteContent const allStudies = Array.isArray(content?.studies) ? content.studies : [] - const allEpisodes = Array.isArray(content?.podcastFeaturedLinks) ? content.podcastFeaturedLinks : [] + const allEpisodes = [ + ...(Array.isArray(content?.podcastFeaturedLinks) ? content.podcastFeaturedLinks : []), + ...(Array.isArray(content?.finishedBooks) ? content.finishedBooks.flatMap(book => (Array.isArray(book?.highlights) ? book.highlights : [])) : []), + ] const cutoff = new Date() const entries = [] diff --git a/src/AdminPage.tsx b/src/AdminPage.tsx index 742227b..115f434 100644 --- a/src/AdminPage.tsx +++ b/src/AdminPage.tsx @@ -14,6 +14,20 @@ import InboxPanel, { type InboxSubmission } from './InboxPanel' import AssetManager, { type AdminAsset } from './AssetManager' +type HighlightLane = 'primary' | 'second' | 'general' + +function highlightLaneOf(link: PodcastFeaturedLink): HighlightLane { + return link.lane === 'second' || link.lane === 'general' ? link.lane : 'primary' +} + +// Splits highlights into the ones belonging to a series (moved onto its Finished Book) and the rest (kept). +function splitHighlightsForLane(links: PodcastFeaturedLink[] | undefined, lane: HighlightLane) { + const all = links ?? [] + const ending = all.filter(link => highlightLaneOf(link) === lane).map(({ lane: _lane, ...link }) => link) + const kept = all.filter(link => highlightLaneOf(link) !== lane) + return { ending, kept } +} + function toLocalInputValue(iso?: string): string { if (!iso) return '' const d = new Date(iso) @@ -2216,6 +2230,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) ...(f.podcastFeaturedLinks ?? []), { id: Date.now().toString(36), + lane: 'primary' as const, title: '', episodeNumber: '', summary: '', @@ -4154,6 +4169,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) setForm(f => { const cur = f.secondSeries if (!cur?.title?.trim()) return f + const { ending: endingHighlights, kept: keptHighlights } = splitHighlightsForLane(f.podcastFeaturedLinks, 'second') const archived = { id: Date.now().toString(36), title: cur.title, @@ -4161,9 +4177,11 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) imageUrl: cur.imageUrl, season: cur.season ?? 1, ...(cur.studySlug ? { studySlug: cur.studySlug } : {}), + ...(endingHighlights.length > 0 ? { highlights: endingHighlights } : {}), } return { ...f, + podcastFeaturedLinks: keptHighlights, finishedBooks: [...(f.finishedBooks ?? []), archived], studies: (f.studies ?? []).map(st => st.slug === cur.studySlug && st.status !== 'planned' ? { ...st, status: 'complete' as const } : st), secondSeries: undefined, @@ -4207,6 +4225,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) className="btn-primary" disabled={!endSeriesNewTitle.trim() || !endSeriesNewSeason.trim()} onClick={() => { + const { ending: endingHighlights, kept: keptHighlights } = splitHighlightsForLane(form.podcastFeaturedLinks, 'primary') const archivedBook = { id: Date.now().toString(36), title: form.seriesTitle, @@ -4214,6 +4233,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) imageUrl: form.seriesImageUrl, season: form.seriesSeason ?? (parseInt(endSeriesNewSeason) - 1 || 1), ...(form.seriesStudySlug ? { studySlug: form.seriesStudySlug } : {}), + ...(endingHighlights.length > 0 ? { highlights: endingHighlights } : {}), } setForm(f => ({ ...f, @@ -4221,7 +4241,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date()) seriesStudySlug: '', seriesSeason: parseInt(endSeriesNewSeason) || undefined, finishedBooks: [...(f.finishedBooks ?? []), archivedBook], - podcastFeaturedLinks: f.secondSeries?.title?.trim() ? f.podcastFeaturedLinks : [], + podcastFeaturedLinks: keptHighlights, seriesTitle: endSeriesNewTitle.trim(), seriesImageUrl: endSeriesNewImage.trim() || f.seriesImageUrl, seriesLabel: 'Now Playing', @@ -4475,6 +4495,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
Groups this highlight under its series on the Episodes page. When a series ends, its highlights move onto that book's Finished Books page. General highlights stay.
+{link.summary}
} + Listen → + > + ) + if (!hasRichContent && link.url) { + return {inner} + } + return {inner} +} + +// Highlights are grouped by the series they belong to, so each book being studied gets its own row. function PodcastHighlightsSection({ content }: { content: SiteContent }) { const links = [...(content.podcastFeaturedLinks ?? [])].reverse() if (links.length === 0) return null + const laneOf = (link: PodcastFeaturedLink) => (link.lane === 'second' ? 'second' : link.lane === 'general' ? 'general' : 'primary') + const secondTitle = content.secondSeries?.title?.trim() + const groups = [ + { key: 'primary', title: content.seriesTitle, links: links.filter(link => laneOf(link) === 'primary') }, + { key: 'second', title: secondTitle, links: links.filter(link => laneOf(link) === 'second') }, + { key: 'general', title: 'More Highlights', links: links.filter(link => laneOf(link) === 'general') }, + ].filter(group => group.links.length > 0) + // Only label the rows when there is more than one to tell apart + const showGroupTitles = groups.length > 1 + return ({link.summary}
} - Listen → - > - ) - - if ('external' in dest) { - return ( - - {inner} - - ) - } - return ( - - {inner} - - ) - })} -Loading episodes…
diff --git a/src/content.ts b/src/content.ts index d840b88..a49551e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -68,6 +68,9 @@ export interface RedirectRule { export interface PodcastFeaturedLink { id: string + // Which series this highlight belongs to: Lane A (primary), Lane B (second), or general. + // Missing = primary (older highlights were all about the one running series). + lane?: 'primary' | 'second' | 'general' title: string episodeNumber?: string summary: string @@ -110,6 +113,8 @@ export interface FinishedBook { season: number // The study that goes with this book, so the card can offer both "Listen" and "Study" studySlug?: string + // Episode highlights that were featured while this series was playing, kept for its page + highlights?: PodcastFeaturedLink[] downloadUrl?: string downloadQrUrl?: string } @@ -666,3 +671,11 @@ export const DEFAULTS: SiteContent = { ], }, } + +// Highlights currently featured plus those archived onto finished books (so their detail pages keep working). +export function getAllHighlights(content: Pick