mirror of
https://github.com/Ad-closeNN/blog-fuwari.git
synced 2026-05-31 01:20:06 -04:00
style(config): 在 Profile 页加入了提交信息
2. typo(pages): new-domain.md 多拼写了双引号
This commit is contained in:
@@ -5,7 +5,6 @@ import { url } from "../../utils/url-utils";
|
||||
import ImageWrapper from "../misc/ImageWrapper.astro";
|
||||
|
||||
const config = profileConfig;
|
||||
|
||||
const isSunday = new Date().getDay() === 0;
|
||||
---
|
||||
<div class="card-base p-3">
|
||||
@@ -29,7 +28,18 @@ const isSunday = new Date().getDay() === 0;
|
||||
<div class="px-2">
|
||||
<div class="font-bold text-xl text-center mb-1 dark:text-neutral-50 transition">{config.name}</div>
|
||||
<div class="h-1 w-5 bg-[var(--primary)] mx-auto rounded-full mb-2 transition"></div>
|
||||
|
||||
<!-- bio: 名言部分 -->
|
||||
<!-- 星期日 -->
|
||||
{ isSunday &&
|
||||
<div class="text-center text-neutral-400 mb-2.5 transition">调整你的步伐,跟着节拍摇摆,举起双手拥抱你想成为的人</div>
|
||||
}
|
||||
|
||||
<!-- 其他日 -->
|
||||
{ !isSunday &&
|
||||
<div class="text-center text-neutral-400 mb-2.5 transition">{config.bio}</div>
|
||||
}
|
||||
|
||||
<div class="flex gap-2 justify-center mb-1">
|
||||
{config.links.length > 1 && config.links.map(item =>
|
||||
<a rel="me" aria-label={item.name} href={item.url} target="_blank" class="btn-regular rounded-lg h-10 w-10 active:scale-90">
|
||||
@@ -51,13 +61,23 @@ const isSunday = new Date().getDay() === 0;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 最新 Commit 提交信息 -->
|
||||
<div class="text-center text-sm text-neutral-500 dark:text-neutral-400 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700">
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<Icon name="ic:baseline-commit" class="text-base"></Icon>
|
||||
<span><a id="github-commit-link" href="#" target="_blank">
|
||||
<span id="github-commit">加载中...</span></a></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 星期日 -->
|
||||
{isSunday &&
|
||||
{ isSunday &&
|
||||
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=250 height=86 src="//music.163.com/outchain/player?type=2&id=2155423467&auto=0&height=66"></iframe>
|
||||
}
|
||||
|
||||
<!-- 其他日 -->
|
||||
{!isSunday &&
|
||||
{ !isSunday &&
|
||||
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=250 height=86 src="//music.163.com/outchain/player?type=2&id=2608813264&auto=0&height=66"></iframe>
|
||||
}
|
||||
</div>
|
||||
@@ -77,7 +97,7 @@ fetch("https://v1.hitokoto.cn")
|
||||
.catch(error => {
|
||||
console.error("获取一言失败:", error);
|
||||
//document.getElementById("hitokoto").innerText = "获取失败,请稍后再试。";
|
||||
//失败后用内置的,成功了用别人的。不过,这真的可能用失败吗?
|
||||
//失败后用内置的,成功了用别人的。
|
||||
document.getElementById("hitokoto").innerText = "再热情的心也经不起冷漠,再爱你的人也经不起冷落。";
|
||||
});
|
||||
</script>
|
||||
@@ -131,4 +151,60 @@ fetch("https://v1.hitokoto.cn")
|
||||
|
||||
// 页面加载完成后获取统计数据
|
||||
document.addEventListener('DOMContentLoaded', loadSiteStats);
|
||||
</script>
|
||||
|
||||
<!-- 获取 Commit 信息 via API -->
|
||||
<script>
|
||||
async function loadCommitStats() {
|
||||
try {
|
||||
// 第零步:检查域名(甚至本地)
|
||||
const statsElement = document.getElementById('github-commit'); // 查找 id
|
||||
const link = document.getElementById('github-commit-link'); // 查找 id
|
||||
|
||||
if (!window.location.hostname.includes('localhost') && !window.location.hostname.includes('adclosenn.top')) {
|
||||
statsElement.textContent = 'Err. invalid domain name';
|
||||
}
|
||||
// 第一步:调用 API
|
||||
const githubResponse = await fetch(`https://api.adclosenn.top/.netlify/functions/commit`);
|
||||
|
||||
if (!githubResponse.ok) {
|
||||
throw new Error('获取信息失败');
|
||||
}
|
||||
|
||||
const Data = await githubResponse.json();
|
||||
|
||||
// 第二步:获取 Commit 数据
|
||||
const latestCommit = Data
|
||||
|
||||
const commitData = {
|
||||
hash: latestCommit.sha.slice(0, 7),
|
||||
fullHash: latestCommit.sha,
|
||||
message: latestCommit.commit.message.split('\n')[0],
|
||||
author: latestCommit.commit.author.name,
|
||||
date: latestCommit.commit.author.date,
|
||||
url: latestCommit.html_url
|
||||
};
|
||||
|
||||
|
||||
if (statsElement) {
|
||||
statsElement.textContent = `当前提交:${Data.sha.slice(0,7)}`;
|
||||
}
|
||||
|
||||
|
||||
if (link){
|
||||
const gurl = "https://github.com/Ad-closeNN/blog-fuwari/commit/"+Data.sha;
|
||||
link.href = gurl;
|
||||
link.title = "("+Data.commit.committer.date + ")" + " " + Data.commit.message;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取 Commit 信息失败:', error);
|
||||
const statsElement = document.getElementById('github-commit');
|
||||
if (statsElement) {
|
||||
statsElement.textContent = '提交信息不可用';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后获取 Commit 数据
|
||||
document.addEventListener('DOMContentLoaded', loadCommitStats);
|
||||
</script>
|
||||
Reference in New Issue
Block a user