diff --git a/src/collections/Pages/pressIndexFields.ts b/src/collections/Pages/pressIndexFields.ts index cc6b630..edbee9c 100644 --- a/src/collections/Pages/pressIndexFields.ts +++ b/src/collections/Pages/pressIndexFields.ts @@ -144,6 +144,7 @@ export const pressIndexFields: Field[] = [ textarea('description', 'Description', pressIndexContent.downloads.description), text('kitLabel', 'Kit label', pressIndexContent.downloads.kitLabel), text('kitMeta', 'Kit metadata', pressIndexContent.downloads.kitMeta), + uploadField('kitFile', 'Press kit file', `Current frontend file: ${pressIndexContent.downloads.kitUrl}`), text('kitUrl', 'Kit URL', pressIndexContent.downloads.kitUrl), text('kitDownloadName', 'Kit download filename', pressIndexContent.downloads.kitDownloadName), text('contactEyebrow', 'Contact eyebrow', pressIndexContent.downloads.contactEyebrow), diff --git a/src/payload-types.ts b/src/payload-types.ts index c2c9bdb..803b0c2 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -1584,6 +1584,10 @@ export interface Page { description?: string | null; kitLabel?: string | null; kitMeta?: string | null; + /** + * Current frontend file: /Print_BMP.zip + */ + kitFile?: (number | null) | Media; kitUrl?: string | null; kitDownloadName?: string | null; contactEyebrow?: string | null; @@ -4474,6 +4478,7 @@ export interface PagesSelect { description?: T; kitLabel?: T; kitMeta?: T; + kitFile?: T; kitUrl?: T; kitDownloadName?: T; contactEyebrow?: T; diff --git a/src/scripts/migrate-spa-media.ts b/src/scripts/migrate-spa-media.ts index fee36c7..a868539 100644 --- a/src/scripts/migrate-spa-media.ts +++ b/src/scripts/migrate-spa-media.ts @@ -20,6 +20,7 @@ const mediaExtensions = new Set([ '.svg', '.webm', '.webp', + '.zip', ]) const mimeByExt: Record = { @@ -33,6 +34,7 @@ const mimeByExt: Record = { '.svg': 'image/svg+xml', '.webm': 'video/webm', '.webp': 'image/webp', + '.zip': 'application/zip', } async function walk(dir: string): Promise { @@ -59,7 +61,7 @@ function isMediaSource(value: string) { async function findSpaSources() { const files = (await walk(spaDir)).filter((file) => /\.(tsx?|jsx?)$/.test(file)) const sources = new Set() - const quotedUrl = /["'`]((?:https?:\/\/images\.unsplash\.com\/[^"'`\s)]+)|(?:\/(?:images\/)?[^"'`\s)]+\.(?:avif|gif|jpe?g|mov|mp4|png|svg|webm|webp)(?:\?[^"'`\s)]*)?))["'`]/gi + const quotedUrl = /["'`]((?:https?:\/\/images\.unsplash\.com\/[^"'`\s)]+)|(?:\/(?:images\/)?[^"'`\s)]+\.(?:avif|gif|jpe?g|mov|mp4|png|svg|webm|webp|zip)(?:\?[^"'`\s)]*)?))["'`]/gi const cssUrl = /url\((['"]?)(.*?)\1\)/g for (const file of files) { diff --git a/src/scripts/preload-press-index-page-cms.ts b/src/scripts/preload-press-index-page-cms.ts index 3c66cba..26e4afc 100644 --- a/src/scripts/preload-press-index-page-cms.ts +++ b/src/scripts/preload-press-index-page-cms.ts @@ -32,10 +32,11 @@ async function main() { const page = pageResult.docs[0] if (!page) throw new Error('Press index page not found. Expected spaPath=/presse or slug=presse/press.') - const [heroImage, eventFallbackImage, newsFallbackImage] = await Promise.all([ + const [heroImage, eventFallbackImage, newsFallbackImage, kitFile] = await Promise.all([ mediaByFilename(payload, pressIndexContent.hero.imageFilename), mediaByFilename(payload, pressIndexContent.events.collectionFallbackImageFilename), mediaByFilename(payload, pressIndexContent.news.collectionFallbackImageFilename), + mediaByFilename(payload, pressIndexContent.downloads.kitDownloadName), ]) const { imageFilename: _heroFilename, ...heroContent } = pressIndexContent.hero const { collectionFallbackImageFilename: _eventFallbackFilename, ...eventsContent } = pressIndexContent.events @@ -61,6 +62,10 @@ async function main() { ...newsContent, collectionFallbackImage: newsFallbackImage, }, + downloads: { + ...pressIndexContent.downloads, + kitFile, + }, }, } as never, }) diff --git a/src/spa/pages/Press.tsx b/src/spa/pages/Press.tsx index bdb9da8..9796b5a 100644 --- a/src/spa/pages/Press.tsx +++ b/src/spa/pages/Press.tsx @@ -18,6 +18,7 @@ type PressIndexCms = Partial & { hero?: Partial & { image?: unknown } events?: Partial & { collectionFallbackImage?: unknown } news?: Partial & { collectionFallbackImage?: unknown } + downloads?: Partial & { kitFile?: unknown } } type PressEventItem = (typeof pressIndexContent.events.fallbackItems)[number] @@ -575,7 +576,7 @@ const Press: React.FC = () => { {/* Download button */} setDlHovered(true)} onMouseLeave={() => setDlHovered(false)}