Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';

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}`;
}
Expand Down