amphora-html 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc CHANGED
@@ -58,7 +58,7 @@
58
58
  "no-trailing-spaces": 2,
59
59
  "no-underscore-dangle": 0,
60
60
  "no-unneeded-ternary": 1,
61
- "one-var": 2,
61
+ "one-var": 0,
62
62
  "quotes": [2, "single", "avoid-escape"],
63
63
  "semi": [2, "always"],
64
64
  "keyword-spacing": 2,
package/lib/media.js CHANGED
@@ -6,6 +6,7 @@ const _ = require('lodash'),
6
6
  bluebird = require('bluebird'),
7
7
  setup = require('./setup'),
8
8
  styleguide = require('./styleguide'),
9
+ url = require('url'),
9
10
  STYLE_TAG = 'style',
10
11
  SCRIPT_TAG = 'scripts',
11
12
  MEDIA_DIRECTORY = path.join(process.cwd(), 'public');
@@ -166,7 +167,7 @@ function injectTags(fileArray, site, tag) {
166
167
  function getMediaMap(state) {
167
168
  return {
168
169
  styles: module.exports.getStyleFiles(state),
169
- scripts: module.exports.getScriptFiles(state)
170
+ scripts: module.exports.getScriptFiles(state),
170
171
  };
171
172
  }
172
173
 
@@ -238,6 +239,14 @@ function getStyleFiles(state) {
238
239
  }
239
240
  }
240
241
 
242
+ // check for clay compile linked? clay compile font files?
243
+ const defaultFontPath = path.join(assetDir, 'css', '_linked-fonts._default.css');
244
+ const siteFontPath = path.join(assetDir, 'css', `_linked-fonts.${siteStyleguide}.css`);
245
+
246
+ // add any default and site font css
247
+ cssFilePaths.push(defaultFontPath);
248
+ cssFilePaths.push(siteFontPath);
249
+
241
250
  return cssFilePaths
242
251
  .filter(files.fileExists)
243
252
  .map(pathJoin(assetHost, assetPath, assetDir));
package/lib/media.test.js CHANGED
@@ -10,7 +10,8 @@ const _ = require('lodash'),
10
10
 
11
11
  jest.mock('nymag-fs', () => ({
12
12
  fileExists: () => false,
13
- readFilePromise: () => Promise.resolve('')
13
+ readFilePromise: () => Promise.resolve(''),
14
+ tryRequire: () => ({})
14
15
  }));
15
16
 
16
17
  describe(_.startCase(filename), () => {
package/lib/render.js CHANGED
@@ -40,7 +40,7 @@ function applyRenderHooks(ref, data, locals) {
40
40
  * @param {Object} locals
41
41
  * @returns {Function}
42
42
  */
43
- function applyPostRenderHooks(ref, locals) {
43
+ function applyPostRenderHooks(ref, locals, res, self) {
44
44
  return (html) => {
45
45
 
46
46
  // skip postRender hooks in edit mode
@@ -50,7 +50,7 @@ function applyPostRenderHooks(ref, locals) {
50
50
 
51
51
  return setup.plugins.filter((plugin) => plugin.postRender)
52
52
  .reduce((val, plugin) => {
53
- return plugin.postRender(ref, html, locals);
53
+ return plugin.postRender(ref, html, locals, res, self);
54
54
  }, html);
55
55
  };
56
56
  }
@@ -148,7 +148,7 @@ function render(data, meta, res) {
148
148
  return applyRenderHooks(state._layoutRef || state.self, data, state.locals)
149
149
  .then(makeHtml(state))
150
150
  .then(mediaService.injectScriptsAndStyles(state))
151
- .then(applyPostRenderHooks(state._layoutRef || state.self, state.locals))
151
+ .then(applyPostRenderHooks(state._layoutRef || state.self, state.locals, res, meta._ref))
152
152
  .then(result => {
153
153
  res.type('text/html');
154
154
  res.send(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amphora-html",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "An HTML renderer for component data",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,6 +20,7 @@
20
20
  "traverse": "^0.6.6"
21
21
  },
22
22
  "devDependencies": {
23
+ "clayhandlebars": "^5.0.1",
23
24
  "coveralls": "^3.0.2",
24
25
  "eslint": "^3.19.0",
25
26
  "jest": "23.6.0"