-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
37 lines (32 loc) · 1.17 KB
/
index.mjs
File metadata and controls
37 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import fs from 'fs'
import path from 'path'
import rimrafCallback from 'rimraf'
import { promisify } from 'util'
import loadPosts from './util/loadPosts.mjs'
import compileArchive from './util/compileArchive.mjs'
import compilePosts from './util/compilePosts.mjs'
import compileSass from './util/compileSass.mjs'
import copyImages from './util/copyImages.mjs'
import makeDeploymentHook from './util/makeDeploymentHook.mjs'
import root from './root.mjs'
const fsPromises = fs.promises
const rimraf = promisify(rimrafCallback)
const postsPath = path.join(root, 'posts')
const publicPath = path.join(root, 'public')
const templatesPath = path.join(root, 'templates')
const stylesPath = path.join(root, 'styles')
const imagesPath = path.join(root, 'images')
const build = async () => {
// Remove and recreate `public` folder
await rimraf(publicPath)
await fsPromises.mkdir(publicPath)
const posts = await loadPosts(postsPath)
await Promise.all([
compileArchive(posts, templatesPath, publicPath),
compilePosts(posts, templatesPath, publicPath),
compileSass(stylesPath, publicPath),
copyImages(imagesPath, publicPath),
makeDeploymentHook(publicPath),
])
}
build()