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
|
import { Page, PageDirectory } from "./pageDirectory";
import ejs from 'ejs';
import path from 'path';
import buildInfo from "../config/info.js";
import htmlMinify from 'html-minifier-terser';
export async function render(page: Page, pageDirectory: PageDirectory): Promise<string> {
const options = {
page: page,
site: {
pages: pageDirectory,
},
build: buildInfo,
};
const html = await ejs.renderFile(path.join(process.env.VIEWS_DIR, `${page.view}.ejs`), options);
const minifiedHtml = await htmlMinify.minify(html, {
collapseWhitespace: true,
removeComments: true,
continueOnParseError: true,
minifyCSS: true,
minifyJS: true,
});
return minifiedHtml;
}
|