Route publish URLs through MindSpace facade
This commit is contained in:
+10
-7
@@ -1,6 +1,11 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
createMindSpacePublicPageUrl,
|
||||
createMindSpacePublicUrl,
|
||||
createMindSpaceUserRootUrl,
|
||||
} from './mindspace-canonical-url.mjs';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -114,17 +119,15 @@ export function migrateUserPublishDir(h5Root, user, legacyUsersRoot = null) {
|
||||
}
|
||||
|
||||
export function buildPublicUrl(publicBaseUrl, publishKey, filename = '') {
|
||||
const base = `${publicBaseUrl}/${PUBLISH_ROOT_DIR}/${encodeURIComponent(publishKey)}`;
|
||||
if (!filename) return `${base}/`;
|
||||
const clean = filename.replace(/^\/+/, '');
|
||||
return `${base}/${clean.split('/').map(encodeURIComponent).join('/')}`;
|
||||
if (!filename) {
|
||||
return createMindSpaceUserRootUrl({ publicBaseUrl, ownerKey: publishKey });
|
||||
}
|
||||
return createMindSpacePublicUrl({ publicBaseUrl, ownerKey: publishKey, relativePath: filename });
|
||||
}
|
||||
|
||||
/** Public-zone HTML pages live under \`public/\`; share URLs must include that segment. */
|
||||
export function buildPublicZonePageUrl(publicBaseUrl, publishKey, filename) {
|
||||
const clean = String(filename ?? '').replace(/^\/+/, '');
|
||||
const relative = clean.startsWith(`${PUBLIC_ZONE_DIR}/`) ? clean : `${PUBLIC_ZONE_DIR}/${clean}`;
|
||||
return buildPublicUrl(publicBaseUrl, publishKey, relative);
|
||||
return createMindSpacePublicPageUrl({ publicBaseUrl, ownerKey: publishKey, filename });
|
||||
}
|
||||
|
||||
export function renderPublishSkill({ slug, username, publicBaseUrl, publishDir, displayName }) {
|
||||
|
||||
Reference in New Issue
Block a user