Add live reload on changes

This commit is contained in:
khalid@traclabs.com
2026-04-23 08:04:34 -05:00
parent 233fb6d003
commit 36fadf710d
9 changed files with 153 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import crypto from 'node:crypto';
import { stringifyCanonical } from '@dynamic-sites/shared';
import { writeAuditLog } from '../db.js';
import { logger } from '../logger.js';
import { broadcastReload } from '../live-reload.js';
const REPO_ROOT = process.env.REPO_ROOT || '.';
const MAX_BACKUPS = 20;
@@ -70,4 +71,13 @@ export function writeContentFile(
});
logger.info({ event: 'content.written', path: repoRelativePath, size: canonical.length }, 'Content file written');
// Notify any connected browsers to reload.
broadcastReload('content.written', {
path: repoRelativePath,
proposalId: opts?.proposalId,
source: opts?.source,
beforeHash,
afterHash,
});
}