2024-11-27
This commit is contained in:
24
utils/shortcodes.js
Normal file
24
utils/shortcodes.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const markdownit = require('markdown-it')
|
||||
const md = markdownit({html: true})
|
||||
const { DateTime } = require("luxon");
|
||||
|
||||
module.exports = {
|
||||
shortcodes: {
|
||||
timeTag: (datetime, format = "MMMM d, yyyy") => {
|
||||
dt = DateTime.fromJSDate(new Date(datetime))
|
||||
return `<time>${dt.toFormat(format)}</time>`
|
||||
}
|
||||
},
|
||||
|
||||
pairedShortcodes: {
|
||||
prologue: (content) =>{
|
||||
const html = md.render(content)
|
||||
return `<h1>Prologue</h1><hr><section class="prologue"><div>${html}</div></section>`
|
||||
},
|
||||
|
||||
alternateTitles: (content) => { return `<section class="alternate-titles"><h1>Alternate Titles</h1><hr>${md.render(content)}</section>` },
|
||||
|
||||
summary: (content) => { return `<section class="summary"><h1>Summary</h1><hr>${md.render(content)}</section>`
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user