Back to home

landpad/

pages

Version: 0.2.0

Last Updated: Unknown


LandPad Pages Template

Use this tempalate to generate different pages.

At the time of writing, this should only generate the / index page but this can be used for anything.

Module files

1#!/usr/bin/env node
2const path = require('path');
3const dir = __dirname;
4const cwd = process.cwd();
5
6let filesErr = [];
7
8const build = ({ dependencies, data, output, basedir }) => {
9 dependencies.ejs.renderFile(`${dir}/page.ejs`, data, {}, function (err, str) {
10 // str => Rendered HTML string
11 if (err) {
12 filesErr.push(output);
13 throw err;
14 }
15
16 // output should be a mix of the Lift folder
17 const outputFilePath = `${basedir}/pages/${output}.tsx`;
18 dependencies.fs.outputFileSync(outputFilePath, str);
19 });
20};
21
22module.exports = async function (options) {
23 console.log('Bridging LandPad Pages');
24 try {
25 const basedir = options.data.basedir
26 ? path.resolve(cwd, options.data.basedir)
27 : cwd;
28
29 // 1. Build out the locale content files
30 for (const page of options.data) {
31 console.log(`\t - Scaffolding: ${page.path}`);
32 build({
33 ...options,
34 basedir,
35 output: page.name,
36 data: page,
37 });
38 }
39
40 return options;
41 } catch (err) {
42 console.error(err);
43 }
44};

Install


Lift generate


Repository

https://github.com/okeeffed/pkg-lift-landpad

Sections