Browse Source

Fix layouts path.

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

6
layouts/page.hbs

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

22
server.js

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

Loading…
Cancel
Save