Files
blog-code/src/components/Footer.astro
2025-12-08 19:47:53 +08:00

52 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
import * as fs from "node:fs";
import * as path from "node:path";
import { footerConfig, profileConfig } from "../config";
import { url } from "../utils/url-utils";
const currentYear = new Date().getFullYear();
// 页脚自定义内容逻辑
let customFooterHtml = "";
if (footerConfig.enable) {
// 优先使用 customHtml如果为空则使用 FooterConfig.html 文件内容
if (footerConfig.customHtml && footerConfig.customHtml.trim() !== "") {
customFooterHtml = footerConfig.customHtml.trim();
} else {
// customHtml 为空时,读取 FooterConfig.html 文件内容
try {
const footerConfigPath = path.join(
process.cwd(),
"src",
"FooterConfig.html",
);
customFooterHtml = fs.readFileSync(footerConfigPath, "utf-8");
// 移除HTML注释
customFooterHtml = customFooterHtml
.replace(/<!--[\s\S]*?-->/g, "")
.trim();
} catch (error) {
console.warn("FooterConfig.html文件读取失败:", error.message);
}
}
}
---
<!--<div class="border-t border-[var(&#45;&#45;primary)] mx-16 border-dashed py-8 max-w-[var(&#45;&#45;page-width)] flex flex-col items-center justify-center px-6">-->
<div class="transition border-t border-black/10 dark:border-white/15 my-10 border-dashed mx-32"></div>
<!--<div class="transition bg-[oklch(92%_0.01_var(&#45;&#45;hue))] dark:bg-black rounded-2xl py-8 mt-4 mb-8 flex flex-col items-center justify-center px-6">-->
<div class="transition border-dashed border-[oklch(85%_0.01_var(--hue))] dark:border-white/15 rounded-2xl mb-12 flex flex-col items-center justify-center px-6">
<div class="transition text-50 text-sm text-center">
{customFooterHtml && (
<div class="mb-2" set:html={customFooterHtml}></div>
)}
&copy; <span id="copyright-year">{currentYear}</span> {profileConfig.name}. 千里之行,始于足下.
Powered by
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://astro.namyki.top">Namyki</a> <br/>
<a class="transition link text-[var(--primary)] font-medium" href={url('rss/')} onclick={`event.preventDefault(); navigateToPage('${url('rss/')}')`}>RSS</a> /
<a class="transition link text-[var(--primary)] font-medium" href={url('atom/')} onclick={`event.preventDefault(); navigateToPage('${url('atom/')}')`}>Atom</a> /
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href={url('sitemap-index.xml')}>Sitemap</a>
</div>
</div>