diff --git a/src/Filters/Slugify.js b/src/Filters/Slugify.js index 033f1868a..5bb4f1fcc 100644 --- a/src/Filters/Slugify.js +++ b/src/Filters/Slugify.js @@ -1,5 +1,7 @@ const slugify = require("@sindresorhus/slugify"); module.exports = function(str, options = {}) { - return slugify(str, options); + return slugify(str, Object.assign({ + decamelize: false + }, options)); }; diff --git a/test/TemplateTest_Permalink.js b/test/TemplateTest_Permalink.js index 6f27e7246..1ce3729d0 100644 --- a/test/TemplateTest_Permalink.js +++ b/test/TemplateTest_Permalink.js @@ -200,7 +200,7 @@ test("Using slugify filter!", async (t) => { t.is(await tmpl.getOutputPath(), "./dist/subdir/slug-love-candidate-lyublyu/index.html"); }); -test("Using slugify filter with comma", async (t) => { +test("Using slugify filter with comma and apostrophe", async (t) => { let tmpl = getNewTemplate( "./test/slugify-filter/comma.njk", "./test/slugify-filter/", @@ -209,3 +209,23 @@ test("Using slugify filter with comma", async (t) => { t.is(await tmpl.getOutputPath(), "./dist/subdir/hi-i-m-zach/index.html"); }); + +test("Using slug filter with options params", async (t) => { + let tmpl = getNewTemplate( + "./test/slugify-filter/slug-options.njk", + "./test/slugify-filter/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/subdir/hi_i_am_zach/index.html"); +}); + +test("Using slugify filter with options params", async (t) => { + let tmpl = getNewTemplate( + "./test/slugify-filter/slugify-options.njk", + "./test/slugify-filter/", + "./dist" + ); + + t.is(await tmpl.getOutputPath(), "./dist/subdir/hi-i-m-z-ach/index.html"); +}); diff --git a/test/slugify-filter/comma.njk b/test/slugify-filter/comma.njk index 051808553..fd3a31fca 100644 --- a/test/slugify-filter/comma.njk +++ b/test/slugify-filter/comma.njk @@ -1,5 +1,5 @@ --- -title: "Hi, I'm Zach" +title: "Hi, I'm ZAch" permalink: subdir/{{ title | slugify }}/index.html --- Slugged. diff --git a/test/slugify-filter/slug-options.njk b/test/slugify-filter/slug-options.njk new file mode 100644 index 000000000..543d5a6d2 --- /dev/null +++ b/test/slugify-filter/slug-options.njk @@ -0,0 +1,5 @@ +--- +title: "Hi, I am ZAch" +permalink: "subdir/{{ title | slug({replacement:'_'}) }}/index.html" +--- +Slugged. diff --git a/test/slugify-filter/slugify-options.njk b/test/slugify-filter/slugify-options.njk new file mode 100644 index 000000000..c958c1874 --- /dev/null +++ b/test/slugify-filter/slugify-options.njk @@ -0,0 +1,5 @@ +--- +title: "Hi, I'm ZAch" +permalink: "subdir/{{ title | slugify({decamelize: true}) }}/index.html" +--- +Slugged.