Files
jiang13-bbs/frontend/lib/sitePagePath.ts
freefire 803b694659 后台单页和公告改为正文优先编辑,保存与发布分开。
列表按列对照真实路径和状态,避免把 /p/ 前缀和发布操作混在一起。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 01:07:21 +08:00

14 lines
575 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.
/** 单页公开路径。前台路由是 /p/[slug],列表、复制和线上查看必须用同一条。 */
export function sitePagePublicPath(slug: string): string {
const clean = slug.trim();
if (!clean) return "/p/";
return `/p/${encodeURIComponent(clean)}`;
}
/** 用当前页面的 origin 拼绝对地址,不写死域名。origin 为空时只返回路径。 */
export function sitePagePublicURL(origin: string, slug: string): string {
const path = sitePagePublicPath(slug);
const base = origin.replace(/\/$/, "");
return base ? `${base}${path}` : path;
}