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 @@
"use client";
import PostComposer from "@/components/PostComposer";
import { useUrlStyle } from "@/components/SiteBrandProvider";
import { postPath } from "@/lib/urlStyle";
import type { PostAttachment } from "@/lib/api";
type Props = {
@@ -34,6 +36,7 @@ export default function EditPostClient({
boardColorIndex = 0,
boardIcon,
}: Props) {
const urlStyle = useUrlStyle();
return (
<PostComposer
mode="edit"
@@ -50,7 +53,7 @@ export default function EditPostClient({
boardId={boardId}
boardColorIndex={boardColorIndex}
boardIcon={boardIcon}
cancelHref={`/post/${postId}`}
cancelHref={postPath(urlStyle, postId)}
/>
);
}

View File

@@ -1,9 +1,10 @@
import { cookies } from "next/headers";
import { notFound, redirect } from "next/navigation";
import { authCookieHeader } from "@/lib/cookies";
import { getMeCached } from "@/lib/serverData";
import { getMeCached, getPublicSettingsCached } from "@/lib/serverData";
import { fetchPostDetail } from "@/lib/api";
import { canModerateBoard } from "@/lib/roles";
import { postPath } from "@/lib/urlStyle";
import EditPostClient from "./EditPostClient";
interface PageProps {
@@ -29,7 +30,8 @@ export default async function EditPostPage({ params }: PageProps) {
me.user.id === post.user.id ||
canModerateBoard(me.user, post.board_id);
if (!allowed) {
redirect(`/post/${id}`);
const urlStyle = (await getPublicSettingsCached()).url_style;
redirect(postPath(urlStyle, post.id));
}
return (