feat: Tage als geschlossen markierbar (Feiertage o. Ä.)
Im Wochenplan lässt sich pro Tag ein optionaler, mehrsprachiger Schließungsgrund hinterlegen. Geschlossene Tage werden auf der öffentlichen Speisekarte (Desktop + mobil) und im RSS-Feed als "Geschlossen" statt mit Essenszeiten angezeigt, im Wochenplan bleibt "Mahlzeit hinzufügen" für diesen Tag deaktiviert.
This commit is contained in:
+25
-16
@@ -1,5 +1,6 @@
|
||||
import { query } from "@/lib/db";
|
||||
import { loadMenuEntries } from "@/lib/db/menu-entries";
|
||||
import { listClosedDays } from "@/lib/db/closed-days";
|
||||
import { addDays, entriesFor, formatPrice, mondayOf, todayISO } from "@/lib/menu";
|
||||
import { localized, SITE_TITLE } from "@/lib/types";
|
||||
import type { Section } from "@/lib/types";
|
||||
@@ -45,30 +46,38 @@ export async function GET() {
|
||||
// Wochennavigation anzeigt.
|
||||
const rangeEnd = addDays(monday, 11);
|
||||
|
||||
const [sections, entries] = await Promise.all([
|
||||
const [sections, entries, closedDays] = await Promise.all([
|
||||
query<Section>("select * from sections order by sort"),
|
||||
loadMenuEntries(monday, rangeEnd),
|
||||
listClosedDays(monday, rangeEnd),
|
||||
]);
|
||||
|
||||
const days = Array.from(new Set(entries.map((e) => e.menu_date))).sort();
|
||||
const days = Array.from(
|
||||
new Set([...entries.map((e) => e.menu_date), ...closedDays.map((c) => c.closed_date)])
|
||||
).sort();
|
||||
|
||||
const items = days
|
||||
.map((iso) => {
|
||||
const dayContent = sections
|
||||
.map((s) => {
|
||||
const dishes = entriesFor(entries, iso, s.key);
|
||||
if (dishes.length === 0) return "";
|
||||
const list = dishes
|
||||
.map(
|
||||
(e) =>
|
||||
`<li>${escapeXml(localized(e.dish, "de"))} – ${formatPrice(e.dish.price)}</li>`
|
||||
)
|
||||
const closed = closedDays.find((c) => c.closed_date === iso);
|
||||
const dayContent = closed
|
||||
? `<p><strong>Geschlossen</strong>${
|
||||
closed.reason ? ` – ${escapeXml(closed.reason)}` : ""
|
||||
}</p>`
|
||||
: sections
|
||||
.map((s) => {
|
||||
const dishes = entriesFor(entries, iso, s.key);
|
||||
if (dishes.length === 0) return "";
|
||||
const list = dishes
|
||||
.map(
|
||||
(e) =>
|
||||
`<li>${escapeXml(localized(e.dish, "de"))} – ${formatPrice(e.dish.price)}</li>`
|
||||
)
|
||||
.join("");
|
||||
return `<p><strong>${escapeXml(localized(s, "de"))} (${escapeXml(
|
||||
s.time_range
|
||||
)})</strong></p><ul>${list}</ul>`;
|
||||
})
|
||||
.join("");
|
||||
return `<p><strong>${escapeXml(localized(s, "de"))} (${escapeXml(
|
||||
s.time_range
|
||||
)})</strong></p><ul>${list}</ul>`;
|
||||
})
|
||||
.join("");
|
||||
if (!dayContent) return "";
|
||||
|
||||
const [y, m, d] = iso.split("-").map(Number);
|
||||
|
||||
Reference in New Issue
Block a user