refactor: 改用 id 標記以配合其餘程式碼風格
This commit is contained in:
@@ -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", '');
|
||||
|
||||
Reference in New Issue
Block a user