From cf154c399b2263a7b176c8616f1bd91752468249 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Thu, 23 Nov 2023 02:51:57 -0800 Subject: [PATCH] fixed error in paragraph rows --- next.config.js | 27 +++++++++++++++---------- src/components/paragraphs/rows/rows.tsx | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/next.config.js b/next.config.js index d955d279..0f6b9d9f 100644 --- a/next.config.js +++ b/next.config.js @@ -1,18 +1,23 @@ const drupalUrl = new URL(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL); +const imagePatterns = [ + { + // Allow any stanford domain for images, but require https. + protocol: 'https', + hostname: '**.stanford.edu', + }, + { + protocol: drupalUrl.protocol.replace(':', ''), + hostname: drupalUrl.hostname, + }, +]; +if (process.env.NEXT_IMAGE_DOMAIN) { + imagePatterns.push({hostname: process.env.NEXT_IMAGE_DOMAIN}) +} + const nextConfig = { images: { - remotePatterns: [ - { - // Allow any stanford domain for images, but require https. - protocol: 'https', - hostname: '**.stanford.edu', - }, - { - protocol: drupalUrl.protocol.replace(':', ''), - hostname: drupalUrl.hostname, - }, - ], + remotePatterns: imagePatterns, }, async rewrites() { return { diff --git a/src/components/paragraphs/rows/rows.tsx b/src/components/paragraphs/rows/rows.tsx index 74a4a579..b0026880 100644 --- a/src/components/paragraphs/rows/rows.tsx +++ b/src/components/paragraphs/rows/rows.tsx @@ -17,7 +17,7 @@ const Rows = async ({components}: { components: StanfordParagraph[] }) => { const layouts: Layout = {}; const draftMode = isDraftMode(); - components = await getResources(components, draftMode); + components = (await getResources(components, draftMode)).filter(item => !!item); // Set the layouts first. components.map(item => {