后台单页和公告改为正文优先编辑,保存与发布分开。
列表按列对照真实路径和状态,避免把 /p/ 前缀和发布操作混在一起。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
13
frontend/lib/sitePagePath.ts
Normal file
13
frontend/lib/sitePagePath.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/** 单页公开路径。前台路由是 /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;
|
||||
}
|
||||
Reference in New Issue
Block a user