|
|
@ -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; |
|
|
|