From 07a82347312cdfed9af0022e4cb350d7bfa41544 Mon Sep 17 00:00:00 2001 From: noeFly Date: Sat, 21 Jun 2025 23:20:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=B9=E7=94=A8=20id=20=E6=A8=99?= =?UTF-8?q?=E8=A8=98=E4=BB=A5=E9=85=8D=E5=90=88=E5=85=B6=E9=A4=98=E7=A8=8B?= =?UTF-8?q?=E5=BC=8F=E7=A2=BC=E9=A2=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/rehype-component-gitlab-card.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/rehype-component-gitlab-card.mjs b/src/plugins/rehype-component-gitlab-card.mjs index 89f2906..a0b08b5 100644 --- a/src/plugins/rehype-component-gitlab-card.mjs +++ b/src/plugins/rehype-component-gitlab-card.mjs @@ -35,7 +35,7 @@ export function GitlabCardComponent(properties, children) { h("div", { class: "gc-user" }, repo.split("/")[0]), ]), h("div", { class: "gc-divider" }, "/"), - h("div", { class: `gc-repo ${cardUuid}-repo` }, repo.split("/")[1]), + h(`div#${cardUuid}-repo`, { class: "gc-repo" }, repo.split("/")[1]), ]), h("div", { class: "github-logo" }), ]); @@ -55,7 +55,7 @@ export function GitlabCardComponent(properties, children) { ` fetch('https://gitlab.com/api/v4/projects/${repoE}').then(response => response.json()).then(data => { console.log(data); - document.getElementsByClassName('${cardUuid}-repo')[0].innerText = data.name; + document.getElementById('${cardUuid}-repo').innerText = data.name; 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", '');