Libraryify slugify

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-04-07 10:32:23 -07:00
parent dbce40d195
commit 98b9fd7934
3 changed files with 7 additions and 4 deletions

View File

@ -10,8 +10,7 @@ const Handlebars = require('handlebars');
const HandlebarsKit = require('hbs-kit'); const HandlebarsKit = require('hbs-kit');
HandlebarsKit.load(Handlebars); HandlebarsKit.load(Handlebars);
const slugs = require('slugify'); const slugify = require('./lib/slugify');
const slugify = (s) => slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase();
const striptags = require('string-strip-html'); const striptags = require('string-strip-html');
const markdownIt = require('markdown-it'); const markdownIt = require('markdown-it');

5
build/lib/slugify.js Normal file
View File

@ -0,0 +1,5 @@
const slugs = require('slugify');
module.exports = exports = function slugify (s) {
return slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase();
};

View File

@ -3,8 +3,7 @@ const path = require('path');
const { without } = require('lodash'); const { without } = require('lodash');
const { resolve, isCleanUrl, TYPE, ENGINE } = require('./resolve'); const { resolve, isCleanUrl, TYPE, ENGINE } = require('./resolve');
const Page = require('./page'); const Page = require('./page');
const slugs = require('slugify'); const slugify = require('./lib/slugify');
const slugify = (s) => slugs(s, { remove: /[*+~.,()'"!?:@/\\]/g }).toLowerCase();
const pkg = require(resolve('package.json')); const pkg = require(resolve('package.json'));
const postmatch = /(\d{4}-\d\d-\d\d)\.\d{4}\.(\w+)/; const postmatch = /(\d{4}-\d\d-\d\d)\.\d{4}\.(\w+)/;