From 5ae0f701c326e4041cd97df5f142df5a0be18605 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Fri, 22 Apr 2022 21:21:59 +0300 Subject: [PATCH] Fix layouts path. --- layouts/page-container.hbs | 6 +++--- layouts/page.hbs | 6 +++--- server.js | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/layouts/page-container.hbs b/layouts/page-container.hbs index 3d07220..e58dd23 100644 --- a/layouts/page-container.hbs +++ b/layouts/page-container.hbs @@ -1,10 +1,10 @@ -{{> layouts/partials/head }} +{{> (include_partial "layouts/partials/head") }} -{{> layouts/partials/toolbar }} +{{> (include_partial "layouts/partials/toolbar") }}
@@ -12,7 +12,7 @@
-{{> layouts/partials/scripts }} +{{> (include_partial "layouts/partials/scripts") }} diff --git a/layouts/page.hbs b/layouts/page.hbs index 0fce1fb..b77c1ee 100644 --- a/layouts/page.hbs +++ b/layouts/page.hbs @@ -1,16 +1,16 @@ -{{> layouts/partials/head }} +{{> (include_partial "layouts/partials/head") }} -{{> layouts/partials/toolbar }} +{{> (include_partial "layouts/partials/toolbar") }}
{{> src/template }}
-{{> layouts/partials/scripts }} +{{> (include_partial "layouts/partials/scripts") }} diff --git a/server.js b/server.js index 2dd0088..9aea28c 100755 --- a/server.js +++ b/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;