- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接 - 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配 - 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成 - middleware 与相关组件适配
14 lines
668 B
TypeScript
14 lines
668 B
TypeScript
import { pagePath, type UrlStyle } from "./urlStyle.ts";
|
||
|
||
/** 单页公开路径。前台路由是 /p/[slug](伪静态风格跟随站点设置),列表、复制和线上查看必须用同一条。 */
|
||
export function sitePagePublicPath(slug: string, style: UrlStyle = "default"): string {
|
||
return pagePath(style, slug);
|
||
}
|
||
|
||
/** 用当前页面的 origin 拼绝对地址,不写死域名。origin 为空时只返回路径。 */
|
||
export function sitePagePublicURL(origin: string, slug: string, style: UrlStyle = "default"): string {
|
||
const path = sitePagePublicPath(slug, style);
|
||
const base = origin.replace(/\/$/, "");
|
||
return base ? `${base}${path}` : path;
|
||
}
|