summary refs log tree commit diff stats
path: root/src/domain
diff options
context:
space:
mode:
authorAlan Pearce2017-06-25 13:03:41 +0200
committerAlan Pearce2017-06-25 13:03:41 +0200
commita7960192e2a268c02643a9374adb4d8798c15d5a (patch)
tree14944f52d9f7d2686a4a61d35747ad1b6e798215 /src/domain
parent6061d1e5b5bdd67ab958c7cedc2f3fe5712e3ea2 (diff)
downloadhomestead-a7960192e2a268c02643a9374adb4d8798c15d5a.tar.lz
homestead-a7960192e2a268c02643a9374adb4d8798c15d5a.tar.zst
homestead-a7960192e2a268c02643a9374adb4d8798c15d5a.zip
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
Diffstat (limited to 'src/domain')
-rw-r--r--src/domain/posts.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/domain/posts.js b/src/domain/posts.js
index 14bc7cc..aedf58e 100644
--- a/src/domain/posts.js
+++ b/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 getTitle (file) {
 function get (filename) {
   const fileMatter = matter.read(filename, grayMatterOptions)
   fileMatter.basename = getTitle(fileMatter)
+  delete fileMatter.orig
+  fileMatter.body = markdown(fileMatter.content)
   return canonicaliseMetadata(fileMatter)
 }