Version: 0.2.0
Last Updated: Unknown
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.
1#!/usr/bin/env node2const path = require('path');3const dir = __dirname;4const cwd = process.cwd();56let filesErr = [];78const build = ({ dependencies, data, output, basedir }) => {9 dependencies.ejs.renderFile(`${dir}/page.ejs`, data, {}, function (err, str) {10 // str => Rendered HTML string11 if (err) {12 filesErr.push(output);13 throw err;14 }1516 // output should be a mix of the Lift folder17 const outputFilePath = `${basedir}/pages/${output}.tsx`;18 dependencies.fs.outputFileSync(outputFilePath, str);19 });20};2122module.exports = async function (options) {23 console.log('Bridging LandPad Pages');24 try {25 const basedir = options.data.basedir26 ? path.resolve(cwd, options.data.basedir)27 : cwd;2829 // 1. Build out the locale content files30 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 }3940 return options;41 } catch (err) {42 console.error(err);43 }44};
1<<%= module.name %>2 <% _%>3 <%_ Object.entries(module.props).forEach(function([key, value], i) { _%>4 <%= key %>={<%- typeof value === 'string' ? `'${value}'` : typeof value === 'object' ? JSON.stringify(value) : value %>}5 <%_ }); _%>6 <%_ Object.entries(module.i18n).forEach(function([key, value], i) { _%>7 <%= key %>={<%- typeof value === 'object' ? JSON.stringify(value).replace(/"(f[^"]+)",?/g, "$1,") : value %>}8 <%_ }); _%>9 <% %>10/>
1import { useIntl } from 'react-intl';2import {3 <% _%>4 <%_ imports.forEach(function(module) { _%>5 <%= module.name %>,6 <%_ }); _%>7 <% %>8} from '@landpadapp/component-library'9import Layout from '../components/Layout';1011const IndexPage = () => {12 const { formatMessage } = useIntl();13 const f = (id: string) => formatMessage({ id });1415 return (16 <Layout title="Home | Next.js + TypeScript Example">17 <%_ modules.forEach(function(module, i){ _%>18 <%- include('./module.ejs', {module: module}) %>19 <%_ }); _%>20 </Layout>21 );22}2324export default IndexPage;