From bd4f0e8b63a7b4eb30846b7e9e285c094fc42025 Mon Sep 17 00:00:00 2001 From: saicaca Date: Sat, 20 Jul 2024 23:24:19 +0800 Subject: [PATCH] fix: failed GitHub API requests no longer break the href of repo card & style tweak --- src/components/misc/Markdown.astro | 9 ++++----- src/plugins/rehype-component-github-card.mjs | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/misc/Markdown.astro b/src/components/misc/Markdown.astro index 06ddb3c..8e59b0e 100644 --- a/src/components/misc/Markdown.astro +++ b/src/components/misc/Markdown.astro @@ -441,23 +441,22 @@ const className = Astro.props.class; opacity: 0.7 transition: opacity 0.15s ease-in-out - .gc-description, .gc-infobar + .gc-description, .gc-infobar, .gc-avatar background-color: var(--tw-prose-body) color: transparent opacity: 0.5; - border-radius: 0.5rem animation: pulsate 2s infinite linear user-select: none &:before background-color: transparent - .gc-avatar - display: none - .gc-repo margin-left: -0.1rem + .gc-description, .gc-infobar + border-radius: 0.5rem + a.card-github.fetch-error pointer-events: all opacity: 1 diff --git a/src/plugins/rehype-component-github-card.mjs b/src/plugins/rehype-component-github-card.mjs index 70737c5..58a532b 100644 --- a/src/plugins/rehype-component-github-card.mjs +++ b/src/plugins/rehype-component-github-card.mjs @@ -78,7 +78,6 @@ 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}-card').href = data.html_url; document.getElementById('${cardUuid}-description').innerText = data.description.replace(/:[a-zA-Z0-9_]+:/g, ''); 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", '');