From 6942887e6499ee0a1ad8116be2382d2d29571542 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Tue, 18 Nov 2025 23:18:57 -0800 Subject: [PATCH 1/2] Handle empty thumbnail specification --- src/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 5ddcc79..e900ccf 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -41,8 +41,15 @@ export function downloadUrl(kind: string, source: string, ref: string, isTag = f // https://raw.githubusercontent.com/myst-templates/arxiv_nips/main/thumbnail.png export function thumbnailUrl(source: string, thumbnail: string, ref: string) { + // Thumbnail wasn't specified; nothing we can do + if (!thumbnail) return null; + const parts = getGithubParts(source); + + // If we don't have a GitHub source URL, then the thumbnail has to be absolute; return as-is if (!parts) return thumbnail; + + // GitHub source and thumbnail path provided; assume thumbnail path is relative const relative = thumbnail.replace(/^\.?\//, ''); return `https://raw.githubusercontent.com/${parts.org}/${parts.repo}/${ref}/${relative}`; } From b1515b9e10f5808ec3dd117412d7e89e5b8e78c3 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Tue, 18 Nov 2025 23:35:11 -0800 Subject: [PATCH 2/2] Avoid changing return type of thumbnailURL --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index e900ccf..556492c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -42,7 +42,7 @@ export function downloadUrl(kind: string, source: string, ref: string, isTag = f // https://raw.githubusercontent.com/myst-templates/arxiv_nips/main/thumbnail.png export function thumbnailUrl(source: string, thumbnail: string, ref: string) { // Thumbnail wasn't specified; nothing we can do - if (!thumbnail) return null; + if (!thumbnail) return ''; const parts = getGithubParts(source);