Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 1.17 KB

readme.md

File metadata and controls

17 lines (11 loc) · 1.17 KB

A companion filter for Pelican Comment System

Pelican is a fantastic Python powered static site generator. It's mature, has many plugins and is pretty fast! Maybe not Hugo fast, but fast enough for a Python enthusiast :)

It's got some cantankerous old bumps though. The class objects generated by Pelican are complex and are not easily serializable for fancy front-end frameworks like VueJS or React. The same problem is inherited by Pelican Comment System.

Fear not! I have written a jinja2 filter that will solve this problem for PCS :D

Clone this repository into whatever Pelican plugins directory you're using, add pcs-serializer to your list of plugins in your pelicanconfig.py, then in your article.html template, use the filter article.comments like so:

<some-vue-component
  comments="{{ article.comments | cserializer | e }}">
</some-vue-component>

Note: the e filter is required after cserializer for escaping the resulting JSON made by the filter. Check your component props, you should now have a shiny new JSON string that you can decode into a useful JS object.