Browse Source

Fix layouts path.

test-gpt-generated
Roman Axelrod 4 years ago
parent
commit
5ae0f701c3
  1. 6
      layouts/page-container.hbs
  2. 6
      layouts/page.hbs
  3. 22
      server.js

6
layouts/page-container.hbs

@ -1,10 +1,10 @@
<html lang="en">
{{> layouts/partials/head }}
{{> (include_partial "layouts/partials/head") }}
<body>
{{> layouts/partials/toolbar }}
{{> (include_partial "layouts/partials/toolbar") }}
<main>
<div class="container">
@ -12,7 +12,7 @@
</div>
</main>
{{> layouts/partials/scripts }}
{{> (include_partial "layouts/partials/scripts") }}
</body>
</html>

6
layouts/page.hbs

@ -1,16 +1,16 @@
<html lang="en">
{{> layouts/partials/head }}
{{> (include_partial "layouts/partials/head") }}
<body>
{{> layouts/partials/toolbar }}
{{> (include_partial "layouts/partials/toolbar") }}
<main>
{{> src/template }}
</main>
{{> layouts/partials/scripts }}
{{> (include_partial "layouts/partials/scripts") }}
</body>
</html>

22
server.js

@ -19,8 +19,8 @@ import fs from "fs/promises";
*/
const isDev = config.get('mode') === 'development';
const modulePath = './node_modules/axe-web-component';
const projectDir = isDev ? '.' : modulePath;
const modulePath = 'node_modules/axe-web-component/';
const projectDir = isDev ? '' : modulePath;
console.log('Development Mode:', isDev);
const sass = gulpSass(dartSass);
@ -37,7 +37,7 @@ const hbs = create({
app.engine('.hbs', hbs.engine);
app.set('view engine', '.hbs');
app.set('views', projectDir + '/layouts');
app.set('views', projectDir + 'layouts');
app.get('/', async (req, res) => {
let dataFiles = await fs.readdir('./data');
@ -56,13 +56,25 @@ app.get('/', async (req, res) => {
const jsonFileName = (req.query.data) ? req.query.data : 'default';
const data = await fsExtra.readJson(`./data/${jsonFileName}.json`);
Object.assign(data, {config}, {config: {projectDir, dataFiles}});
Object.assign(data, {
config: {
projectDir,
dataFiles,
cssUrl: config.get('cssUrl')
}
});
data.helpers = {
include_partial(path) {
return projectDir + path;
}
}
res.render('page-container', data);
});
app.use(express.static('src'));
app.use(express.static('layouts'));
app.use(express.static(projectDir + 'layouts'));
const listener = app.listen(0, () => {
const PORT = listener.address().port;

Loading…
Cancel
Save