后台设置和内容编辑改成可导航布局;部署用访客 origin 生成 Canonical,避免落到容器地址。 Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import pkg from "../package.json";
|
||
import type { FooterLink } from "@/lib/brand";
|
||
import FooterTiming from "./FooterTiming";
|
||
|
||
// 官方镜像构建会写入 NEXT_PUBLIC_APP_VERSION(可与脚手架 0.1.0 相同)。
|
||
// 未注入时,脚手架默认号仍当未发布,页脚显示占位。
|
||
function realVersion(pkgVersion: string): string {
|
||
const injected = process.env.NEXT_PUBLIC_APP_VERSION?.trim();
|
||
if (injected) return injected;
|
||
return !pkgVersion || pkgVersion === "0.0.0" || pkgVersion === "0.1.0" ? "" : pkgVersion;
|
||
}
|
||
|
||
// 极简页脚:左侧版权 / 版本 / 耗时,右侧备案等链接
|
||
export default function Footer({
|
||
siteName = "姜十三社区",
|
||
links = [],
|
||
}: {
|
||
siteName?: string;
|
||
links?: FooterLink[];
|
||
}) {
|
||
const year = new Date().getFullYear();
|
||
const brand = siteName.trim() || "姜十三社区";
|
||
const visibleLinks = links.filter((item) => item.label.trim() && item.url.trim());
|
||
|
||
return (
|
||
<footer
|
||
style={{
|
||
borderTop: "1px solid var(--line)",
|
||
background: "var(--panel)",
|
||
}}
|
||
>
|
||
<div className="max-w-[1440px] mx-auto px-4 sm:px-6 py-4 flex items-center justify-between gap-x-4 gap-y-2 flex-wrap">
|
||
<div className="flex items-center gap-x-3 gap-y-1 flex-wrap min-w-0">
|
||
<span className="meta text-[12px] whitespace-nowrap">© {year} {brand}</span>
|
||
<FooterTiming version={realVersion(pkg.version)} />
|
||
</div>
|
||
{visibleLinks.length > 0 ? (
|
||
<nav aria-label="页脚链接" className="flex flex-wrap items-center justify-end gap-x-3 gap-y-1 min-w-0 ml-auto">
|
||
{visibleLinks.map((item) => (
|
||
<a
|
||
key={`${item.label}-${item.url}`}
|
||
href={item.url}
|
||
className="meta text-[12px] hover:underline"
|
||
{...(item.new_tab ? { target: "_blank", rel: "noopener noreferrer" } : {})}
|
||
>
|
||
{item.label}
|
||
</a>
|
||
))}
|
||
</nav>
|
||
) : null}
|
||
</div>
|
||
</footer>
|
||
);
|
||
}
|