Skip to content

Commit 2af3ebf

Browse files
authored
Merge pull request #116 from mcampa/STENCIL-3394-bug
STENCIL-3394 should not append configId if the file is not in assets/…
2 parents 7c235b2 + e42ebb9 commit 2af3ebf

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

helpers/stylesheet.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ function helper(paper) {
66
paper.handlebars.registerHelper('stylesheet', function (assetPath) {
77
const options = arguments[arguments.length - 1];
88
const configId = paper.settings['theme_config_id'];
9-
const path = configId ? assetPath.replace(/\.css$/, `-${configId}.css`) : assetPath;
9+
// append the configId only if the asset path starts with assets/css/
10+
const path = configId && assetPath.match(/^\/?assets\/css\//)
11+
? assetPath.replace(/\.css$/, `-${configId}.css`)
12+
: assetPath;
13+
1014
const url = paper.cdnify(path);
1115

1216
let attrs = { rel: 'stylesheet' };

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bigcommerce/stencil-paper",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A stencil plugin to register partials and helpers from handlebars and returns the compiled version for the stencil platform.",
55
"main": "index.js",
66
"author": "Bigcommerce",

test/helpers/stylesheet.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ describe('stylesheet helper', () => {
4343

4444
done();
4545
});
46+
47+
it('should not append configId if the file is not in assets/css/ directory', done => {
48+
expect(c('{{{stylesheet "assets/lib/style.css" }}}', { theme_config_id: 'foo' }))
49+
.to.be.equal('<link data-stencil-stylesheet href="/assets/lib/style.css" rel="stylesheet">');
50+
51+
done();
52+
});
4653
});

0 commit comments

Comments
 (0)