resources.js 655 B

12345678910111213141516171819202122
  1. const _path = require('path');
  2. const _fs = require('fs-magic');
  3. const _jsonReader = require('./json-reader');
  4. // wrapper to add custom options
  5. module.exports = async function loadResources(opt){
  6. // load page template
  7. const template = opt.template && await _fs.readFile(opt.template, 'utf8');
  8. // load styles
  9. const stylesheet = opt.stylesheet && await _fs.readFile(opt.stylesheet, 'utf8');
  10. // load page definitions
  11. const pages = opt.lang && await _jsonReader(_path.join(__dirname, '../i18n/pages-' + opt.lang + '.json'));
  12. return {
  13. template: template,
  14. stylesheet: stylesheet,
  15. pages: pages
  16. };
  17. }