feat: 可配置站点 URL 风格

- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接
- 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配
- 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成
- middleware 与相关组件适配
This commit is contained in:
2026-09-27 04:01:42 +08:00
parent 1d862a0dd3
commit 7a44c1f2cf
64 changed files with 1183 additions and 200 deletions

View File

@@ -1,6 +1,8 @@
import Link from "next/link";
import { Pin } from "lucide-react";
import type { PostListItem } from "@/lib/api";
import { postPath } from "@/lib/urlStyle";
import { getPublicSettingsCached } from "@/lib/serverData";
import Avatar from "./Avatar";
import { IconComment, IconEye } from "./Icons";
@@ -15,7 +17,7 @@ function formatTime(dateStr: string) {
* 管理员置顶区:独立于普通帖子列表。
* 陶土色语义(与 badge-pin 一致),紧凑排列,一眼识别为公告性质内容。
*/
export default function PinnedPosts({
export default async function PinnedPosts({
posts,
showBoard = true,
}: {
@@ -23,6 +25,7 @@ export default function PinnedPosts({
showBoard?: boolean;
}) {
if (posts.length === 0) return null;
const urlStyle = (await getPublicSettingsCached()).url_style;
return (
<section className="mb-6" aria-label="置顶讨论">
@@ -43,7 +46,7 @@ export default function PinnedPosts({
{posts.map((p, i) => (
<Link
key={p.id}
href={`/post/${p.id}`}
href={postPath(urlStyle, p.id)}
className="group relative flex items-center gap-3 sm:gap-3.5 px-4 sm:px-5 py-3.5 transition-colors hover:bg-[var(--item-hover-bg)] focus-visible:bg-[var(--item-hover-bg)] j13-fade-up"
style={{
...(i > 0 ? { borderTop: "1px solid var(--line)" } : {}),