Files
jiang13-bbs/frontend/lib/sitePagePath.ts
freefire 7a44c1f2cf feat: 可配置站点 URL 风格
- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接
- 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配
- 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成
- middleware 与相关组件适配
2026-09-27 04:01:42 +08:00

14 lines
668 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}