From 929bc9f9f82d8d4f6fb6decd218ca5032e0ba9ab Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 25 May 2025 13:09:54 -0700 Subject: [PATCH] fix(oembed.php): remove fallback hardcoded values; correct case where description might be empty --- api/oembed.php | 22 +++++++++------------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/api/oembed.php b/api/oembed.php index df0f4b8..6c8968f 100644 --- a/api/oembed.php +++ b/api/oembed.php @@ -16,11 +16,12 @@ class OembedHandler extends BaseHandler $relativePath = $parsed['path'] ?? null; if (!$requestUrl || $relativePath === '/') $this->sendResponse($this->buildResponse( - $globals['site_name'], - $globals['url'], - $globals['metadata']['open_graph_image'], - $globals - )); + $globals['site_name'], + $globals['url'], + $globals['metadata']['open_graph_image'], + $globals, + $globals['site_description'] + )); if (!$relativePath) $this->sendErrorResponse('Invalid url', 400); @@ -89,8 +90,8 @@ class OembedHandler extends BaseHandler 'provider_name' => $globals['site_name'], 'provider_url' => $globals['url'], 'thumbnail_url' => $globals['url'] . '/og/w800' . $imagePath, - 'html' => $html, - 'description' => $safeDescription, + 'html' => $html ?? $globals['site_description'], + 'description' => $safeDescription ?? $globals['site_description'], ]; } @@ -100,12 +101,7 @@ class OembedHandler extends BaseHandler if ($this->cache && $this->cache->exists($cacheKey)) return json_decode($this->cache->get($cacheKey), true); - $globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0] ?? [ - 'author' => 'Cory Dransfeldt', - 'site_name' => 'coryd.dev', - 'url' => 'https://www.coryd.dev', - 'avatar' => '' - ]; + $globals = $this->fetchFromApi('optimized_globals', 'limit=1')[0]; if ($this->cache) $this->cache->setex($cacheKey, 3600, json_encode($globals)); diff --git a/package-lock.json b/package-lock.json index b2bb08c..bc60309 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "7.0.7", + "version": "7.0.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "7.0.7", + "version": "7.0.8", "license": "MIT", "dependencies": { "minisearch": "^7.1.2", diff --git a/package.json b/package.json index e9f33a5..270c7d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "7.0.7", + "version": "7.0.8", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "engines": {