Add live reload on changes
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user