posativ / acrylamid

(unmaintained) static blog generator in python with incremental rendering ⛺
http://posativ.org/acrylamid/
Other
277 stars 40 forks source link

Extract first image of the article so you can display it next to the article on the main page #177

Closed minimalme closed 11 years ago

minimalme commented 11 years ago

Hi,

Is there a way to extract the first image of each article and to display it next to the article on the main page?

You can see an example in the attached image:

capture

posativ commented 11 years ago

No, but you can add a custom key pair to the metadata section:

---
title: Bla
front: /img/bla.png
---

and now in your template, you can link to env.path ~ entry.front (but make sure, entry.front is set).

minimalme commented 11 years ago

Ah great! Thanks I will try it. What do you mean by entry.front set?

posativ commented 11 years ago

If you always add an image to your posts, you can probably ignore it – but if not, you may need this in your template:

{% if entry.front is defined %}
<img ...>
{% endif %}
minimalme commented 11 years ago

Yes I always add it but thanks for the tip :).

Acrylamid is really great and thanks for your support!