鹈鹕 - 添加图像到摘要

时间:2017-05-16 02:13:03

标签: 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

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

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

3 个答案:

答案 0 :(得分:5)

将图片添加为文章中的字段元数据,将其标记为“VertexID”,如下所示:

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

此行在元数据中查找{% if article.cover %}<img src="{{ article.cover }}" alt="">{% endif %} {{ article.summary }} 键,如果有,则创建Cover标记。如果不是,那就简单地通过。

答案 1 :(得分:1)

在那里使用article.summary广告。我使用了pelican-theme alchemy (使用bootstrap),article.summary位于index.html。我把它扩展如下:

  <div class="col-sm-8">
    <h4 class="title"><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></h4>
    <div class="content">
      {{ article.summary|striptags }}
      {% if article.cover %}           
         <div class="container"><div class="col-md-6" style="padding-left: 0px;  padding-right: 0px;">
           <img src="{{ article.cover }}" class="img-fluid">
           </div></div>   
      {% endif %} 
    </div>
  </div>

这适用于我使用 images - 文件夹中的图片。 enter image description here

但是我还有一个问题:帖子找不到相同的图片 - 文件夹中的图片: - (

答案 2 :(得分:0)

对于那些在Pelican中使用AboutWilson模板的人,我已经设法通过在index.html文件中添加以下代码(在模板文件夹中)来使其工作

{% if article.cover %}
Cover:
<span> 
    <img src="{{ article.cover }}" alt=""> 
</span>
{% endif %}

enter image description here

相关问题