Skip to content

Commit

Permalink
feat(plugin-sails-content): revert to using ejs to render
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Jul 31, 2024
1 parent 9011a93 commit 8bbb17a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/plugin-sails-content/lib/render.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const fs = require('fs/promises')
const matter = require('gray-matter')
const showdown = require('showdown')
const ejs = require('ejs')

async function render(sails, mdFile, layout) {
const fileContent = await fs.readFile(mdFile, { encoding: 'utf8' })
async function render(filePath, config) {
const fileContent = await fs.readFile(filePath, { encoding: 'utf8' })
const { data, content } = matter(fileContent)

layout = layout || data.layout
const layout = data.layout || config.layout

const converter = new showdown.Converter({ ghCompatibleHeaderId: true })
const htmlContent = converter.makeHtml(content)

const layoutContent = await fs.readFile(layout, { encoding: 'utf8' })

const renderedHtml = await sails.renderView(layoutContent, {
layout: false,
const renderedHtml = ejs.render(layoutContent, {
...config.locals,
data,
content: htmlContent
})
Expand Down

0 comments on commit 8bbb17a

Please sign in to comment.