Skip to content

Commit 929dcae

Browse files
committed
fix generate additional params
1 parent 611356d commit 929dcae

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ $ npm install gitbook-plugin-jsfiddle --save
2525
Param `type` can be 'frame' or 'script'.
2626
Also you can use other params read more https://medium.com/jsfiddle-updates/new-jsfiddle-embeds-93ab7a51ee11#.vt34bxchv
2727
If you need override setting for certain fiddle,you can just add this param in hash
28-
`//jsfiddle.net/zalun/NmudS/#fontColor=green&type=frame`
28+
`https://jsfiddle.net/4o4z6fqn/9/#fontColor=00FF00&type=frame`
2929
### 3. paste jsfiddle embedded code to you book something like
30-
`[source code](//jsfiddle.net/zalun/NmudS/)`
30+
`[source code](https://jsfiddle.net/4o4z6fqn/9/)`
3131

3232
will be rendered like [my book](https://api.taucharts.com/tutorials/1min.html) does
3333
Also you can see simple example in https://github.com/Mavrin/gitbook-example

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gitbook-plugin-jsfiddle",
33
"description": "JSFiddle Integration into GitBook",
44
"main": "index.js",
5-
"version": "1.0.0-alpha.6",
5+
"version": "1.0.0-alpha.7",
66
"author": {
77
"name": "Konstantin Krivlenia"
88
},

src/replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ var generateAdditionalParams = function (config) {
4545
if (config.theme) {
4646
params += config.theme + '/';
4747
}
48-
var colors = _.chain(config).omit('href', 'type', 'theme', 'tabs', 'width', 'height').reduce(function (colors, value, color) {
48+
var colors = _.chain(config).omit(['href', 'type', 'theme', 'tabs', 'width', 'height']).reduce(function (colors, value, color) {
4949
colors += color + '=' + value + '&';
5050
return colors;
51-
}, '');
51+
}, '').value();
5252
colors = colors.replace(/&$/, '');
5353
if (colors) {
5454
return params + '?' + colors;

tests/replace.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ test('replacer', function (assert) {
1616
<script async src="//jsfiddle.net/zalun/NmudS/embed/js/dark/?bodyColor=red&accentColor=red"></script>
1717
</div>`.replace(/\s+/g, ' ')
1818
, 'replace on script with params and dark theme');
19+
assert.equal(
20+
replace(str, {
21+
type: 'script',
22+
theme: "dark",
23+
tabs: ['js']
24+
}),
25+
`<div>
26+
<script async src="//jsfiddle.net/zalun/NmudS/embed/js/dark/"></script>
27+
</div>`.replace(/\s+/g, ' ')
28+
, 'replace on script without colors params and dark theme');
1929
assert.equal(
2030
replace(str, {
2131
type: 'script',

0 commit comments

Comments
 (0)