From 7cd09b117dcc71028e54b232dddc7babd5857771 Mon Sep 17 00:00:00 2001 From: noeFly Date: Sun, 22 Jun 2025 00:29:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=20GitLab=20=E7=B6=B2?= =?UTF-8?q?=E5=9D=80=E4=BD=BF=E7=94=A8=E9=8C=AF=E8=AA=A4=E7=9A=84=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/rehype-component-gitlab-card.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/rehype-component-gitlab-card.mjs b/src/plugins/rehype-component-gitlab-card.mjs index d3466eb..7467fa9 100644 --- a/src/plugins/rehype-component-gitlab-card.mjs +++ b/src/plugins/rehype-component-gitlab-card.mjs @@ -58,8 +58,13 @@ export function GitlabCardComponent(properties, children) { document.getElementById('${cardUuid}-description').innerText = data.description?.replace(/:[a-zA-Z0-9_]+:/g, '') || "Description not set"; document.getElementById('${cardUuid}-forks').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.forks_count).replaceAll("\u202f", ''); document.getElementById('${cardUuid}-stars').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.star_count).replaceAll("\u202f", ''); - const avatarEl = document.getElementById('${cardUuid}-avatar'); - document.getElementById('${cardUuid}-avatar').style.backgroundImage = 'url(' + data.namespace.avatar_url + ')'; + + const avatar_url = data.namespace.avatar_url; + if (avatar_url.startsWith('/')) { + document.getElementById('${cardUuid}-avatar').style.backgroundImage = 'url(https://gitlab.com' + avatar_url + ')'; + } else { + document.getElementById('${cardUuid}-avatar').style.backgroundImage = 'url(' + avatar_url + ')'; + } document.getElementById('${cardUuid}-avatar').style.backgroundColor = 'transparent'; document.getElementById('${cardUuid}-card').classList.remove("fetch-waiting"); console.log("[GITLAB-CARD] Loaded card for ${repo} | ${cardUuid}.")