Change font size depending on post length
One of the things that I like about Twitter is that the font size changes depending on the length of the tweet. Yesterday, I tried to achieve the same thing for this Jekyll based blog and came up with the following solution.
First, I created a plugin (in the folder
_plugins) and registered it as
Liquid filter with the following code:
As a next step I changed the
post.html template to this:
It is important to remove the
<p> tags because they cannot be nested in valid HTML and Jekyll adds their own tags to post content.
Finally, I created some SCSS to change the
font-size based on the CSS class.