darthmeme / gridsome-plugin-rss

Generate an RSS feed from your Gridsome data store
16 stars 11 forks source link

How to generate HTML in description? #2

Closed johannesholmberg closed 5 years ago

johannesholmberg commented 5 years ago

If I would like to generate the whole output of a post in the description, how do I do it?

node.content puts out the raw markdown of the post, but how can I convert it to HTML before putting it out?

Thanks! @darthmeme

darthmeme commented 5 years ago

Hey @johannesholmberg

You'll need to use a library such as marked to parse the markdown into HTML.

For example (assuming that node.description is markdown):

// in gridsome.config.js
const marked = require('marked')

// inside gridsome-plugin-rss options
feedItemOptions: node => ({
  title: node.title,
  description: marked(node.description),
  url: 'https://superblog.com/post/' + node.slug,
  author: node.fields.author
}),
johannesholmberg commented 5 years ago

@darthmeme

Thanks for helping out. Works like a charm 👍