import type { Tagged } from 'type-fest'; import type { ResourceId } from './resource-id.js'; /** 发布页面的 ID */ export type PageId = Tagged; export const PageMode = ['iframe'] as const; /** 页面发布模式 */ export type PageMode = (typeof PageMode)[number]; /** 发布页面 */ export interface Page { /** 发布页面的 ID */ pageId: PageId; /** 关联的资源 */ resource: ResourceId; /** 页面索引键 */ key: string; /** 页面路径 */ path: string; /** 页面发布模式 */ mode: PageMode; } /** 页面发布 URL */ export function toPageUrl(pageId: PageId, base?: string | URL): string { if (!base) return `/page/${pageId}`; return new URL(`/page/${pageId}`, base).href; }