feat: 可配置站点 URL 风格
- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接 - 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配 - 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成 - middleware 与相关组件适配
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
/** 单页公开路径。前台路由是 /p/[slug],列表、复制和线上查看必须用同一条。 */
|
||||
export function sitePagePublicPath(slug: string): string {
|
||||
const clean = slug.trim();
|
||||
if (!clean) return "/p/";
|
||||
return `/p/${encodeURIComponent(clean)}`;
|
||||
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): string {
|
||||
const path = sitePagePublicPath(slug);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user