chore: consolidate filters

This commit is contained in:
Cory Dransfeldt 2024-05-05 15:08:55 -07:00
parent a7fa7379ad
commit 13b80c09cc
No known key found for this signature in database
6 changed files with 14 additions and 17 deletions

View file

@ -1,6 +1,7 @@
import { DateTime } from 'luxon'
import markdownIt from 'markdown-it'
import { URL } from 'url'
import slugify from 'slugify'
import markdownIt from 'markdown-it'
import sanitizeHtml from 'sanitize-html';
import authors from '../data/author-map.js'
@ -23,6 +24,13 @@ export default {
return string.replace(utmPattern, '')
},
replaceQuotes: (string) => string.replace(/"/g, "'"),
slugifyString: (str) => {
return slugify(str, {
replacement: '-',
remove: /[#,&,+()$~%.'":*?<>{}]/g,
lower: true,
})
},
// navigation
isLinkActive: (category, page) => {
@ -45,7 +53,6 @@ export default {
return visitors(b) - visitors(a)
})
},
tagLookup: (url, tagMap) => {
if (!url) return
if (url.includes('openlibrary.org')) return `#Books #NowReading ${tagMap[url]}`.trim()

View file

@ -1,9 +0,0 @@
import slugify from 'slugify'
export const slugifyString = (str) => {
return slugify(str, {
replacement: '-',
remove: /[#,&,+()$~%.'":*?<>{}]/g,
lower: true,
})
}