鹈鹕 - 添加图像到摘要

Eya*_* S. 5 pelican

我正在用鹈鹕创建一个网站.我正在尝试将图像添加到摘要中,以便摘要始终以图像开头.

我尝试将图像添加到元数据中的摘要(使用markdown),但它只显示在索引页面上而不显示在其他页面上(在下面的示例中,图像未显示在"帖子"页面中).我还必须将图像添加到与文本相同的行中,这些文本有时以奇怪的方式呈现(根据图像大小,某些文本位于图像的一侧).

以下是元数据的示例:

Title: this is my title
Slug: slug
Date: 2017-05-04 23:00
Category: Posts
Tags: pelican
Author: Eyal
Summary: ![figure 1](images/fig1.png) and this is my post summary
Run Code Online (Sandbox Code Playgroud)

我也尝试使用摘要插件,但这根本不起作用.

将图像添加到摘要的最简单方法是什么?我希望尽可能避免修改HTML代码.

tol*_*ano 5

将图像添加为文章中的字段元数据,将其标记为" Cover",如下所示:

Title: this is my title
Slug: slug
Date: 2017-05-04 23:00
Category: Posts
Tags: pelican
Author: Eyal
Cover: images/fig1.png
Summary: and this is my post summary
Run Code Online (Sandbox Code Playgroud)

因此,您可以通过这种方式在模板中使用它.

{% if article.cover %}<img src="{{ article.cover }}" alt="">{% endif %} {{ article.summary }}
Run Code Online (Sandbox Code Playgroud)

此行在Cover元数据中查找键,如果有,则创建img标记.如果不是,那么简单地通过.