Skip to content

Commit

Permalink
Merge branch 'saicaca:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NiuBoss123 authored Aug 25, 2024
2 parents dd6087b + 856c2bb commit 19ccd03
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/plugins/rehype-component-github-card.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
document.getElementById('${cardUuid}-description').innerText = data.description.replace(/:[a-zA-Z0-9_]+:/g, '');
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", '');
Expand Down

0 comments on commit 19ccd03

Please sign in to comment.