chore: cleanup and refactor
This commit is contained in:
parent
b6fb54ab98
commit
5295a6eacc
37 changed files with 285 additions and 356 deletions
|
@ -1,7 +1,6 @@
|
|||
const { DateTime } = require('luxon')
|
||||
const markdownIt = require('markdown-it')
|
||||
const { URL } = require('url')
|
||||
const marked = require('marked')
|
||||
const sanitizeHTML = require('sanitize-html')
|
||||
|
||||
const utmPattern = /[?&](utm_[^&=]+=[^&#]*)/gi
|
||||
|
@ -12,16 +11,9 @@ module.exports = {
|
|||
trim: (string, limit) => {
|
||||
return string.length <= limit ? string : `${string.slice(0, limit)}...`
|
||||
},
|
||||
stripIndex: (path) => {
|
||||
return path.replace('/index.html', '/')
|
||||
},
|
||||
mdToHtml: (content) => {
|
||||
return marked.parse(content)
|
||||
},
|
||||
btoa: (string) => {
|
||||
return btoa(string)
|
||||
},
|
||||
dashLower: (string) => string.replace(/\s+/g, '-').toLowerCase(),
|
||||
encodeAmp: (string) => {
|
||||
if (!string) return
|
||||
const pattern = /&(?!(?:[a-zA-Z]+|#[0-9]+|#x[0-9a-fA-F]+);)/g
|
||||
|
@ -54,7 +46,6 @@ module.exports = {
|
|||
},
|
||||
webmentionsByUrl: (webmentions, url) => {
|
||||
const allowedTypes = ['mention-of', 'in-reply-to', 'like-of', 'repost-of']
|
||||
|
||||
const data = {
|
||||
'like-of': [],
|
||||
'repost-of': [],
|
||||
|
|
18
config/transforms/html-config.js
Normal file
18
config/transforms/html-config.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const htmlmin = require('html-minifier-terser')
|
||||
const isProduction = process.env.ELEVENTY_ENV === 'production'
|
||||
|
||||
module.exports = (eleventyConfig) => {
|
||||
eleventyConfig.addTransform('html-minify', (content, path) => {
|
||||
if (path && path.endsWith('.html') && isProduction) {
|
||||
return htmlmin.minify(content, {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseWhitespace: true,
|
||||
decodeEntities: true,
|
||||
includeAutoGeneratedTags: false,
|
||||
removeComments: true,
|
||||
})
|
||||
}
|
||||
|
||||
return content
|
||||
})
|
||||
}
|
Reference in a new issue