Skip to content

Commit

Permalink
Adjust image domains (#3)
Browse files Browse the repository at this point in the history
* Adjust image domains

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup
  • Loading branch information
pookmish authored Nov 24, 2023
1 parent cf154c3 commit 5c17dd4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 31 deletions.
3 changes: 1 addition & 2 deletions app/sitemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const Sitemap = async (): Promise<MetadataRoute.Sitemap> => {

const urls: MetadataRoute.Sitemap = [];


try {
const drupalSitemap: DrupalSitemapItem[] = await fetch(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL + '/sitemap.xml')
const drupalSitemap: DrupalSitemapItem[] = await fetch(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL + '/sitemap.xml', {next: {revalidate: 60}})
.then(response => response.text())
.then<DrupalSitemap>(result => xmlParser.parseStringPromise(result))
.then(sitemap => sitemap['urlset'].url);
Expand Down
33 changes: 17 additions & 16 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
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: imagePatterns,
remotePatterns: [
{
// Allow any stanford domain for images, but require https.
protocol: 'https',
hostname: '**.stanford.edu',
},
{
protocol: drupalUrl.protocol.replace(':', ''),
hostname: drupalUrl.hostname,
},
],
},
async rewrites() {
return {
Expand All @@ -33,6 +28,10 @@ const nextConfig = {
destination: '/_next/image?url=:url',
has: [{ type: 'query', key: 'url', value: '(?<url>.*[jpg|png|jpeg|gif]\?itok=([\\w|-]+)).*' }],
},
{
source: '/wp-:path*',
destination: '/not-found',
}
],
};
},
Expand Down Expand Up @@ -71,6 +70,8 @@ const nextConfig = {
];
},
};
module.exports = nextConfig;

if (process.env.NODE_ENV === 'development') {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
Expand Down
Binary file added public/no-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/lib/drupal/get-resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export async function getResources<T>(items: { type: string, id: string }[], dra

// @ts-ignore
return Promise.all(requests.map((p, i) => p.catch((e) => {
console.error(`Failed Fetching (probably unpublished) component ${items[i].type}-${items[i].id}`, e);
if (`${items[i].type}-${items[i].id}` !== 'unknown-missing') {
console.error(`Failed Fetching (probably unpublished) component ${items[i].type}-${items[i].id}`, e);
}
return null
})));
}
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3140,16 +3140,16 @@
form-data "^4.0.0"

"@types/node@*", "@types/node@^20.1.3":
version "20.9.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.4.tgz#cc8f970e869c26834bdb7ed480b30ede622d74c7"
integrity sha512-wmyg8HUhcn6ACjsn8oKYjkN/zUzQeNtMy44weTJSM6p4MMzEOuKbA3OjJ267uPCOW7Xex9dyrNTful8XTQYoDA==
version "20.9.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.5.tgz#bb441014bcb91c63742b0e1fe25b902f5d581faa"
integrity sha512-Uq2xbNq0chGg+/WQEU0LJTSs/1nKxz6u1iemLcGomkSnKokbW1fbLqc3HOqCf2JP7KjlL4QkS7oZZTrOQHQYgQ==
dependencies:
undici-types "~5.26.4"

"@types/node@^18.0.0":
version "18.18.12"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.12.tgz#0c40e52e5ff2569386b160f6f6bb019ff1361cb4"
integrity sha512-G7slVfkwOm7g8VqcEF1/5SXiMjP3Tbt+pXDU3r/qhlM2KkGm786DUD4xyMA2QzEElFrv/KZV9gjygv4LnkpbMQ==
version "18.18.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.18.13.tgz#ae0f76c0bfe79d8fad0f910b78ae3e59b333c6e8"
integrity sha512-vXYZGRrSCreZmq1rEjMRLXJhiy8MrIeVasx+PCVlP414N7CJLHnMf+juVvjdprHyH+XRy3zKZLHeNueOpJCn0g==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -5137,9 +5137,9 @@ ejs@^3.1.8:
jake "^10.8.5"

electron-to-chromium@^1.4.535:
version "1.4.592"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.592.tgz#1ffd49ba3da3da3077ea20014b066c910d50c913"
integrity sha512-D3NOkROIlF+d5ixnz7pAf3Lu/AuWpd6AYgI9O67GQXMXTcCP1gJQRotOq35eQy5Sb4hez33XH1YdTtILA7Udww==
version "1.4.593"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.593.tgz#f71b157f7382f3d3a164f73ff2da772d4b3fd984"
integrity sha512-c7+Hhj87zWmdpmjDONbvNKNo24tvmD4mjal1+qqTYTrlF0/sNpAcDlU0Ki84ftA/5yj3BF2QhSGEC0Rky6larg==

elliptic@^6.5.3, elliptic@^6.5.4:
version "6.5.4"
Expand Down Expand Up @@ -9805,9 +9805,9 @@ to-regex-range@^5.0.1:
is-number "^7.0.0"

tocbot@^4.20.1:
version "4.22.0"
resolved "https://registry.yarnpkg.com/tocbot/-/tocbot-4.22.0.tgz#10bb34c011c1baa93d2a0e91d25d820856ba4103"
integrity sha512-YHCs00HCNiHxUhksloa36fTfMEXEWV+vdPn3ARQfmj2u3PcUYIjJkfc+ABUfCF9Eb+LSy/QzuLl256fbsRnpHQ==
version "4.23.0"
resolved "https://registry.yarnpkg.com/tocbot/-/tocbot-4.23.0.tgz#5d3788ccf5a8b0ae2c00819b1ed0c127013e2e34"
integrity sha512-5DWuSZXsqG894mkGb8ZsQt9myyQyVxE50AiGRZ0obV0BVUTVkaZmc9jbgpknaAAPUm4FIrzGkEseD6FuQJYJDQ==

[email protected]:
version "1.0.1"
Expand Down

1 comment on commit 5c17dd4

@vercel
Copy link

@vercel vercel bot commented on 5c17dd4 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.