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>` 
    }
  }
}
