From 33225891fa03fa8cfaef2f80912c08db0d3f8e01 Mon Sep 17 00:00:00 2001 From: Ad-closeNN <1709301095@qq.com> Date: Sat, 13 Sep 2025 00:52:21 +0800 Subject: [PATCH] =?UTF-8?q?style(friends):=20=E4=B8=BA=E5=8F=8B=E9=93=BE?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E5=8A=A0=E5=85=A5=E5=8A=A8=E7=94=BB=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2. chore(config): 更改 API 调用链接,从 Netlify Function 改为 GitHub API 3. GitHub Card 中头像 URL avatars.githubusercontent.com 改为 EdgeOne CDN 链接 avatars.gh.api.adclosenn.dev --- src/components/widget/Profile.astro | 8 ++--- src/content/spec/info.md | 7 ++-- src/pages/friends.astro | 37 +++++++++++++++++--- src/plugins/rehype-component-github-card.mjs | 2 +- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/components/widget/Profile.astro b/src/components/widget/Profile.astro index 58bb748..bf9c974 100644 --- a/src/components/widget/Profile.astro +++ b/src/components/widget/Profile.astro @@ -147,16 +147,16 @@ fetch("https://v1.hitokoto.cn") statsElement.textContent = 'Err. invalid domain name'; } // 第一步:调用 API - const githubResponse = await fetch(`https://api.adclosenn.top/.netlify/functions/commit`); + const githubResponse = await fetch(`https://api.github.com/repos/Ad-closeNN/blog-fuwari/commits?per_page=1`); if (!githubResponse.ok) { throw new Error('获取信息失败'); } - const Data = await githubResponse.json(); - + let Data = await githubResponse.json(); + Data = Data[0]; // 第二步:获取 Commit 数据 - const latestCommit = Data + const latestCommit = Data; const commitData = { hash: latestCommit.sha.slice(0, 7), diff --git a/src/content/spec/info.md b/src/content/spec/info.md index 9547448..c7bb9ee 100644 --- a/src/content/spec/info.md +++ b/src/content/spec/info.md @@ -45,16 +45,17 @@ statsElement.textContent = 'Err. invalid domain name'; } // 第一步:调用 API - const githubResponse = await fetch(`https://api.adclosenn.top/.netlify/functions/commit`); + const githubResponse = await fetch(`https://api.github.com/repos/Ad-closeNN/blog-fuwari/commits?per_page=1`); if (!githubResponse.ok) { throw new Error('获取信息失败'); } - const Data = await githubResponse.json(); + let Data = await githubResponse.json(); + Data = Data[0]; // 第二步:获取 Commit 数据 - const latestCommit = Data + const latestCommit = Data; const commitData = { hash: latestCommit.sha.slice(0, 7), diff --git a/src/pages/friends.astro b/src/pages/friends.astro index adc93e1..f1cda34 100644 --- a/src/pages/friends.astro +++ b/src/pages/friends.astro @@ -16,9 +16,9 @@ import { Icon } from "astro-icon/components";
-
Netlify(本站托管平台)
+
Netlify(主站托管平台)
-
AWS CDN,优选后简直不要太香!
+
亚马逊 AWS CDN
@@ -126,7 +126,34 @@ import { Icon } from "astro-icon/components"; diff --git a/src/plugins/rehype-component-github-card.mjs b/src/plugins/rehype-component-github-card.mjs index e37e948..4a4226b 100644 --- a/src/plugins/rehype-component-github-card.mjs +++ b/src/plugins/rehype-component-github-card.mjs @@ -64,7 +64,7 @@ export function GithubCardComponent(properties, children) { 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", ''); const avatarEl = document.getElementById('${cardUuid}-avatar'); - avatarEl.style.backgroundImage = 'url(' + data.owner.avatar_url + ')'; + avatarEl.style.backgroundImage = 'url(' + data.owner.avatar_url.replace("https://avatars.githubusercontent.com", "https://avatars.gh.api.adclosenn.dev") + ')'; avatarEl.style.backgroundColor = 'transparent'; document.getElementById('${cardUuid}-license').innerText = data.license?.spdx_id || "no-license"; document.getElementById('${cardUuid}-card').classList.remove("fetch-waiting");