--- export const prerender = false; import PageLayout from "@/layouts/Base.astro"; import { getFormattedDate } from "@/utils"; type Artwork = { date: string; artwork_id: number; title: string; artist_display: string | null; date_display: string | null; medium_display: string | null; dimensions: string | null; place_of_origin: string | null; credit_line: string | null; short_description: string | null; image_id: string | null; image_url: string | null; source_url: string | null; }; const meta = { title: "/art-calendar", description: "A different painting every day from the Art Institute of Chicago.", }; const FEED_URL = "https://easel.stevedylan.dev/feed.xml"; const today = new Date(); let artwork: Artwork | null = null; let error: string | null = null; try { const res = await fetch("https://easel.stevedylan.dev/api/today", { headers: { Accept: "application/json" }, }); if (!res.ok) throw new Error(`easel returned ${res.status}`); artwork = (await res.json()) as Artwork; } catch (e) { error = e instanceof Error ? e.message : "Failed to reach easel API"; } Astro.response.headers.set( "Cache-Control", "public, max-age=3600, s-maxage=86400", ); ---

/art-calendar

{getFormattedDate(today)}

{ error || !artwork ? (

Couldn't load today's painting{error ? `: ${error}` : ""}.

) : (
{artwork.image_url && ( {artwork.title} )}

{artwork.title}

{artwork.artist_display && (

{artwork.artist_display}

)}
{artwork.date_display && ( <>
Date
{artwork.date_display}
)} {artwork.place_of_origin && ( <>
Origin
{artwork.place_of_origin}
)} {artwork.medium_display && ( <>
Medium
{artwork.medium_display}
)} {artwork.dimensions && ( <>
Dimensions
{artwork.dimensions}
)} {artwork.credit_line && ( <>
Credit
{artwork.credit_line}
)}
{artwork.short_description && (

{artwork.short_description}

)} {artwork.source_url && ( View on artic.edu )}
) }