Skip to content

A plugin for pelican that will serialize pelican_comment_system in a jinja template so that comment data can be easily received by react/vue

Notifications You must be signed in to change notification settings

trev-dev/pcs-serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A plugin for pelican that will serialize pelican_comment_system in a jinja template so that comment data can be easily received by react/vue

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages