From 98b9fd7934d9915bcb31fc79545cbe69b4be3aba Mon Sep 17 00:00:00 2001 From: "Jocelyn Badgley (Twipped)" Date: Tue, 7 Apr 2020 10:32:23 -0700 Subject: [PATCH] Libraryify slugify --- build/engines.js | 3 +-- build/lib/slugify.js | 5 +++++ build/post.js | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 build/lib/slugify.js diff --git a/build/engines.js b/build/engines.js index 6ca8b73..7392916 100644 --- a/build/engines.js +++ b/build/engines.js @@ -10,8 +10,7 @@ const Handlebars = require('handlebars'); const HandlebarsKit = require('hbs-kit'); HandlebarsKit.load(Handlebars); -const slugs = require('slugify'); -const slugify = (s) => slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase(); +const slugify = require('./lib/slugify'); const striptags = require('string-strip-html'); const markdownIt = require('markdown-it'); diff --git a/build/lib/slugify.js b/build/lib/slugify.js new file mode 100644 index 0000000..c25be74 --- /dev/null +++ b/build/lib/slugify.js @@ -0,0 +1,5 @@ +const slugs = require('slugify'); + +module.exports = exports = function slugify (s) { + return slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase(); +}; diff --git a/build/post.js b/build/post.js index 5393245..6e40d41 100644 --- a/build/post.js +++ b/build/post.js @@ -3,8 +3,7 @@ const path = require('path'); const { without } = require('lodash'); const { resolve, isCleanUrl, TYPE, ENGINE } = require('./resolve'); const Page = require('./page'); -const slugs = require('slugify'); -const slugify = (s) => slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase(); +const slugify = require('./lib/slugify'); const pkg = require(resolve('package.json')); const postmatch = /(\d{4}-\d\d-\d\d)\.\d{4}\.(\w+)/;