Just because Lancer is html-first doesn't mean you have to give up nice writing formats like Markdown.
Instead of inventing a new syntax or file type, Lancer gives you access to a simple, yet extremely powerful concept: Custom <template>
tags.
Let's look at an example. Say you have this html file:
<page title="My Page With Markdown">
<template type="markdown">
# Blog: {{page.title}}
This is just a plain old `<template>` tag. *Super* cool!
</template>
Note the type="markdown"
. Lancer does not have special support for markdown, but it does allow you to transform template content!
All you need to do is specify the transform in your site.config.js
file:
import marked from 'marked'
export default {
name: "My Site",
// ...
templateTypes: {
markdown(innerHtml) {
return marked(innerHtml)
}
}
}
And that's it! Lancer will feed the content of your templates (with type="markdown"
) into your templateTypes.markdown
function, and replace it with the output of that function. In this case you'll get:
<!doctype html>
<h1>Blog: My Page With Markdown</h1>
<p>This is just a plain old <code><template></code> tag. <i>Super</i> cool!</p>
Again, this isn't markdown specific; you can specify any template type you want and use it in your code. Have fun with it!