feat: 可配置站点 URL 风格
- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接 - 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配 - 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成 - middleware 与相关组件适配
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
SiteDocAnnoNav,
|
||||
} from "@/components/site-doc";
|
||||
import { requestCanonical } from "@/lib/canonicalMeta";
|
||||
import { pagePath, type UrlStyle } from "@/lib/urlStyle";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return {
|
||||
@@ -30,14 +31,16 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
function PageRow({
|
||||
p,
|
||||
showDivider,
|
||||
urlStyle,
|
||||
}: {
|
||||
p: SitePageSummary;
|
||||
showDivider: boolean;
|
||||
urlStyle: UrlStyle;
|
||||
}) {
|
||||
const Icon = pageGlyph(p.slug);
|
||||
return (
|
||||
<Link
|
||||
href={`/p/${p.slug}`}
|
||||
href={pagePath(urlStyle, p.slug)}
|
||||
className="block px-5 sm:px-6 py-4 sm:py-5 transition-colors hover:bg-[var(--panel-2)] focus-visible:bg-[var(--panel-2)]"
|
||||
style={showDivider ? { borderTop: "1px solid var(--line)" } : undefined}
|
||||
>
|
||||
@@ -90,6 +93,7 @@ export default async function AboutIndexPage() {
|
||||
]);
|
||||
const announcements = overview?.announcements ?? [];
|
||||
const siteLead = settings.site_description?.trim() || undefined;
|
||||
const urlStyle = settings.url_style;
|
||||
const canManagePages = !!me.user && isAdminOrAbove(me.user.role);
|
||||
|
||||
const left = <SiteDocIdentity kind="about" lead={siteLead} />;
|
||||
@@ -146,7 +150,7 @@ export default async function AboutIndexPage() {
|
||||
<p className="meta mt-1.5">有新文档时会显示在这里</p>
|
||||
</div>
|
||||
) : (
|
||||
pages.map((p, i) => <PageRow key={p.id} p={p} showDivider={i > 0} />)
|
||||
pages.map((p, i) => <PageRow key={p.id} p={p} showDivider={i > 0} urlStyle={urlStyle} />)
|
||||
)}
|
||||
</div>
|
||||
</SiteDocShell>
|
||||
|
||||
Reference in New Issue
Block a user