Refactor site generation into a modular content pipeline
Deploy website / deploy (push) Successful in 24s

This commit is contained in:
paul committed 2026-09-22 20:51:13 -04:00
1 parent 0f69028d4a
commit 146d516f24
20 files changed
+826 -427

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { mkdtemp, rename, rm, stat } from 'node:fs/promises'
import { dirname, join } from 'node:path'
const exists = async (path) => {
try {
await stat(path)
return true
} catch (error) {
if (error.code === 'ENOENT') return false
throw error
}
}
export const createOutput = (destination) => mkdtemp(join(dirname(destination), '.generated-next-'))
export const publishOutput = async (staging, destination) => {
const previous = `${staging}-previous`
const hadPrevious = await exists(destination)
if (hadPrevious) await rename(destination, previous)
try {
await rename(staging, destination)
} catch (error) {
if (hadPrevious) await rename(previous, destination)
throw error
}
if (hadPrevious) await rm(previous, { recursive: true })
}
export const discardOutput = (staging) => rm(staging, { recursive: true, force: true })