refactor: re-architect to be closer to ADR
1 file changed, 8 insertions(+), 22 deletions(-)
changed files
M src/modules/posts.js → src/domain/posts.js
@@ -3,19 +3,11 @@ const fs = require('fs') const path = require('path') const matter = require('gray-matter') -const Markdown = require('markdown-it') const grayMatterOptions = { lang: 'toml', delims: '+++' } - -const markdownOptions = { - html: true, - typographer: true -} - -const markdown = new Markdown(markdownOptions) function* lowercaseKeys (iterator) { for (let [k, v] of iterator) {@@ -36,10 +28,6 @@ function getTitle (file) { return path.basename(file.path, path.extname(file.path)) } -function render (post) { - return markdown.render(post.content) -} - function get (filename) { const fileMatter = matter.read(filename, grayMatterOptions) fileMatter.basename = getTitle(fileMatter)@@ -75,14 +63,12 @@ return taxons } -function toTags (posts) { - return taxonomise({ tag: 'tags' }, posts).get('tag') -} - -module.exports = { - get, - getFolder, - toTags, - taxonomise, - render +module.exports = function (config) { + const posts = getFolder(config.folder) + const taxonomies = taxonomise(config.taxonomies, posts) + return { + posts, + taxonomies, + get + } }