diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-08-28 22:02:57 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-08-28 22:02:57 +0100 |
| commit | 7c9abacf956c0e135c1094e38087e018dd572965 (patch) | |
| tree | 866c0a3c27cdaf0bd97ba2403a33349793f3652d /app/builder/renderPage.ts | |
| parent | 7c8ca1c5cf0067a350578d5589139abf076ef1ec (diff) | |
Rename files to more descriptive names
Diffstat (limited to 'app/builder/renderPage.ts')
| -rw-r--r-- | app/builder/renderPage.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/builder/renderPage.ts b/app/builder/renderPage.ts new file mode 100644 index 0000000..7dff22c --- /dev/null +++ b/app/builder/renderPage.ts @@ -0,0 +1,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; +} |
