Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions plugins/airtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,25 @@ async function fetchShareImage(url) {
if (!url || url === "#") return null;

try {
const response = await fetch(url);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);

const response = await fetch(url, {
signal: controller.signal,
headers: {
"User-Agent": "Mozilla/5.0",
},
});

clearTimeout(timeoutId);

if (!response.ok) {
console.warn(
`Failed to fetch share image from ${url}: HTTP ${response.status}`
);
return null;
}

const html = await response.text();
const $ = cheerio.load(html);

Expand All @@ -279,7 +297,6 @@ async function fetchShareImage(url) {
return null;
}
}

function getDefaultEventImage(event) {
const defaultImages = [
"/img/events/event-01.webp",
Expand Down