mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-13 16:26:50 +00:00
Add Spendenregister
This commit is contained in:
11
helpers.js
11
helpers.js
@@ -4,6 +4,7 @@ const { _tr: mdTransformer } = transformer(require('jstransformer-markdown-it'))
|
||||
|
||||
const config = {
|
||||
typographer: true,
|
||||
html: true
|
||||
}
|
||||
|
||||
// monkey-patch render function to pass custom options
|
||||
@@ -22,8 +23,16 @@ const slugify = str => str.toLowerCase()
|
||||
.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '')
|
||||
.replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '')
|
||||
|
||||
const truncate = (str, wordCount) => {
|
||||
const words = str.trim().split(/\s(?![^\[]*\])/g)
|
||||
const head = words.splice(0, wordCount).join(' ')
|
||||
const tail = words.join(' ')
|
||||
return [head, tail]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
markdown: mdTransformer.render,
|
||||
replacements,
|
||||
slugify
|
||||
slugify,
|
||||
truncate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user