// Writes src/paintings.ts and src/coloring.ts from scripts/paintings.json and // scripts/coloring.json (the curated, verified lists). // Run: node scripts/gen-paintings.mjs import fs from 'node:fs' const read = (file) => JSON.parse(fs.readFileSync(new URL(file, import.meta.url), 'utf8')) const paintings = read('./paintings.json').map((p) => ({ id: p.id, title: p.title, artist: p.artist, alt: p.alt, width: p.width, height: p.height, bytes: p.bytes, sourceUrl: p.sourceUrl, imageUrl: p.imageUrl, ...(p.artistSource ? { artistSource: p.artistSource } : {}), })) fs.writeFileSync( new URL('../src/paintings.ts', import.meta.url), `// Generated by scripts/gen-paintings.mjs from scripts/paintings.json. Do not edit by hand. export type Painting = { /** Media Library slug. The app serves the image at {appBase}/img/p/{id}.jpg. */ id: string /** Title exactly as the Church's Media Library page gives it. */ title: string /** Artist exactly as the Church's page gives it. */ artist: string alt: string width: number height: number /** Size of the Church's image file in bytes (for the offline download total). */ bytes: number /** Media Library page for the image. */ sourceUrl: string /** The Church's own image file (a Media Library download size or IIIF rendition). */ imageUrl: string /** Set when the artist comes from the Gospel Art Book page instead of the Media Library page. */ artistSource?: string } export const TERMS_URL = 'https://www.churchofjesuschrist.org/legal/terms-of-use?lang=eng' export const MEDIA_FAQ_URL = 'https://www.churchofjesuschrist.org/tools/help/frequently-asked-questions-about-gospel-media?lang=eng' export const MEDIA_LIBRARY_URL = 'https://www.churchofjesuschrist.org/media?lang=eng' export const COLORING_COLLECTION_URL = 'https://www.churchofjesuschrist.org/media/collection/coloring-pages-images?lang=eng' export const PAINTINGS: Painting[] = ${JSON.stringify(paintings, null, '\t')} `, ) const coloring = read('./coloring.json').map((c) => ({ id: c.id, title: c.title, alt: c.alt, width: c.width, height: c.height, bytes: c.bytes, sourceUrl: c.sourceUrl, imageUrl: c.imageUrl, })) fs.writeFileSync( new URL('../src/coloring.ts', import.meta.url), `// Generated by scripts/gen-paintings.mjs from scripts/coloring.json. Do not edit by hand. export type ColoringPage = { /** Media Library slug. The app serves the image at {appBase}/img/c/{id}.jpg. */ id: string /** Title exactly as the Church's Media Library page gives it. */ title: string alt: string width: number height: number /** Size of the Church's image file in bytes. */ bytes: number /** Media Library page for the coloring page. */ sourceUrl: string /** The Church's own image file. */ imageUrl: string } export const COLORING_PAGES: ColoringPage[] = ${JSON.stringify(coloring, null, '\t')} `, ) console.log(`wrote ${paintings.length} paintings and ${coloring.length} coloring pages`)