fix: fix GitHub repo card not loading with empty description (#154)
This commit is contained in:
parent
b358bddb10
commit
856c2bb2c0
|
@ -59,7 +59,11 @@ export function GithubCardComponent(properties, children) {
|
|||
{ type: 'text/javascript', defer: true },
|
||||
`
|
||||
fetch('https://api.github.com/repos/${repo}', { referrerPolicy: "no-referrer" }).then(response => response.json()).then(data => {
|
||||
if (data.description) {
|
||||
document.getElementById('${cardUuid}-description').innerText = data.description.replace(/:[a-zA-Z0-9_]+:/g, '');
|
||||
} else {
|
||||
document.getElementById('${cardUuid}-description').innerText = "Description not set"
|
||||
}
|
||||
document.getElementById('${cardUuid}-language').innerText = data.language;
|
||||
document.getElementById('${cardUuid}-forks').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.forks).replaceAll("\u202f", '');
|
||||
document.getElementById('${cardUuid}-stars').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.stargazers_count).replaceAll("\u202f", '');
|
||||
|
|
Loading…
Reference in New Issue