This commit is contained in:
parent
b1ebe2ad57
commit
561b28bebf
6 changed files with 223 additions and 38 deletions
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
import { getArchiveEntries } from "../../lib/archive";
|
||||
import { speechAdminEntryFromArchiveEntry } from "../../lib/admin-speeches";
|
||||
import { calendarEvents, recurringCalendarEvents } from "../../data/events";
|
||||
|
||||
const entries = await getArchiveEntries();
|
||||
|
|
@ -17,32 +18,7 @@ const latestEntryDate = latestEntry?.data.published
|
|||
: "No date";
|
||||
const totalEvents = calendarEvents.length + recurringCalendarEvents.length;
|
||||
const configuredServices = [contactFormEndpoint, plausibleDomain].filter(Boolean).length;
|
||||
const speechAdminEntries = speechEntries.map((entry) => {
|
||||
const categories = entry.data.categories ?? [];
|
||||
const tags = entry.data.tags ?? [];
|
||||
const publishedDate = entry.data.published?.slice(0, 10) ?? today;
|
||||
const speechYear = entry.data.speechYear ?? entry.id.match(/\b(1\d{3}|20\d{2})\b/)?.[1] ?? new Date().getFullYear().toString();
|
||||
const categoryText = categories.join(" ").toLowerCase();
|
||||
const collection = entry.data.speechCollection ?? "";
|
||||
const speaker = categoryText.includes("hak ja han") || collection === "mrs-hak-ja-han-moon"
|
||||
? "mrs"
|
||||
: categoryText.includes("rev sun myung moon") || /^\d{4}$/.test(collection) || /^\d{4}$/.test(speechYear)
|
||||
? "rev"
|
||||
: "other";
|
||||
|
||||
return {
|
||||
id: entry.id,
|
||||
path: `content/${entry.id}.md`,
|
||||
title: entry.data.title ?? entry.id,
|
||||
publishedDate,
|
||||
speechYear,
|
||||
speaker,
|
||||
source: entry.data.source ?? "",
|
||||
categories,
|
||||
tags,
|
||||
body: entry.body ?? "",
|
||||
};
|
||||
});
|
||||
const speechAdminEntries = speechEntries.map((entry) => speechAdminEntryFromArchiveEntry(entry, today));
|
||||
const adminConfig = {
|
||||
analyticsDashboardUrl,
|
||||
contactEndpointConfigured: Boolean(contactFormEndpoint),
|
||||
|
|
@ -1265,11 +1241,29 @@ const adminConfig = {
|
|||
}
|
||||
}
|
||||
|
||||
function loadSpeechEditor(speech) {
|
||||
async function loadSpeechEditor(speech) {
|
||||
if (!speechForm) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = document.querySelector("[data-speech-message]");
|
||||
setMessage(message, "Loading speech body...");
|
||||
|
||||
if (!speech.body && speech.bodyUrl) {
|
||||
try {
|
||||
const response = await fetch(speech.bodyUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Speech body request failed: ${response.status}`);
|
||||
}
|
||||
|
||||
speech = { ...speech, ...(await response.json()) };
|
||||
} catch {
|
||||
setMessage(message, "Could not load that speech body. Try refreshing the admin page.", "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setFormValue(speechForm, "title", speech.title);
|
||||
setFormValue(speechForm, "publishedDate", speech.publishedDate);
|
||||
setFormValue(speechForm, "speechYear", speech.speechYear);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue