fix: URL rewritings for publishing / preview

This commit is contained in:
2026-02-16 21:55:03 +01:00
parent 54a8ba5ceb
commit e98379fe95
8 changed files with 469 additions and 25 deletions

View File

@@ -475,10 +475,12 @@ export function registerIpcHandlers(): void {
safeHandle('media:getUrl', async (_, id: string) => {
// Returns the relative path for a media item (e.g. media/2025/01/uuid.jpg)
// This is the format used in markdown content for image references
// and exposes it as an absolute preview path (e.g. /media/2025/01/uuid.jpg)
// so inserted markdown uses root-absolute URLs.
const engine = getMediaEngine();
const relativePath = await engine.getRelativePath(id);
return relativePath ?? `media/${id}`;
const normalized = relativePath ?? `media/${id}`;
return normalized.startsWith('/') ? normalized : `/${normalized}`;
});
safeHandle('media:getFilePath', async (_, id: string) => {