fix: failed GitHub API requests no longer break the href of repo card & style tweak
This commit is contained in:
parent
f438ea4252
commit
bd4f0e8b63
|
@ -441,23 +441,22 @@ const className = Astro.props.class;
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
transition: opacity 0.15s ease-in-out
|
transition: opacity 0.15s ease-in-out
|
||||||
|
|
||||||
.gc-description, .gc-infobar
|
.gc-description, .gc-infobar, .gc-avatar
|
||||||
background-color: var(--tw-prose-body)
|
background-color: var(--tw-prose-body)
|
||||||
color: transparent
|
color: transparent
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
border-radius: 0.5rem
|
|
||||||
animation: pulsate 2s infinite linear
|
animation: pulsate 2s infinite linear
|
||||||
user-select: none
|
user-select: none
|
||||||
|
|
||||||
&:before
|
&:before
|
||||||
background-color: transparent
|
background-color: transparent
|
||||||
|
|
||||||
.gc-avatar
|
|
||||||
display: none
|
|
||||||
|
|
||||||
.gc-repo
|
.gc-repo
|
||||||
margin-left: -0.1rem
|
margin-left: -0.1rem
|
||||||
|
|
||||||
|
.gc-description, .gc-infobar
|
||||||
|
border-radius: 0.5rem
|
||||||
|
|
||||||
a.card-github.fetch-error
|
a.card-github.fetch-error
|
||||||
pointer-events: all
|
pointer-events: all
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
|
|
@ -78,7 +78,6 @@ export function GithubCardComponent(properties, children) {
|
||||||
{ type: "text/javascript", defer: true },
|
{ type: "text/javascript", defer: true },
|
||||||
`
|
`
|
||||||
fetch('https://api.github.com/repos/${repo}', { referrerPolicy: "no-referrer" }).then(response => response.json()).then(data => {
|
fetch('https://api.github.com/repos/${repo}', { referrerPolicy: "no-referrer" }).then(response => response.json()).then(data => {
|
||||||
document.getElementById('${cardUuid}-card').href = data.html_url;
|
|
||||||
document.getElementById('${cardUuid}-description').innerText = data.description.replace(/:[a-zA-Z0-9_]+:/g, '');
|
document.getElementById('${cardUuid}-description').innerText = data.description.replace(/:[a-zA-Z0-9_]+:/g, '');
|
||||||
document.getElementById('${cardUuid}-language').innerText = data.language;
|
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}-forks').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.forks).replaceAll("\u202f", '');
|
||||||
|
|
Loading…
Reference in New Issue