refactor: move markdown rendering to domain The input and output formats (md -> html) are specific to the domain of blogging, not really a presentation concern. This also means that markdown is rendered to HTML on startup, rather than per-request
1 file changed, 3 insertions(+), 0 deletions(-)
changed files
M src/domain/posts.js → src/domain/posts.js
@@ -3,6 +3,7 @@ const fs = require('fs') const path = require('path') const matter = require('gray-matter') +const markdown = require('../modules/markdown.js') const grayMatterOptions = { lang: 'toml',@@ -31,6 +32,8 @@ function get (filename) { const fileMatter = matter.read(filename, grayMatterOptions) fileMatter.basename = getTitle(fileMatter) + delete fileMatter.orig + fileMatter.body = markdown(fileMatter.content) return canonicaliseMetadata(fileMatter) }