首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Pelican文章摘要中不显示图像?

如何在Pelican文章摘要中不显示图像?
EN

Stack Overflow用户
提问于 2017-08-30 12:47:08
回答 2查看 339关注 0票数 1

如果一篇文章在其元数据部分没有明确的“摘要”,当使用{{ article.summary }}时,Pelican将默认输出50个单词(SUMMARY_MAX_LENGTH = 50)。如果一篇文章的开头包含一个大图像(就尺寸而言),则该大图像将包含在文章摘要中。

当使用{{ article.summary }}的目的是防止文章占用太多空间时,尤其是在列出了所有文章的站点索引页上使用时,这种行为可能会出现问题。

有没有办法防止文章摘要中的图片输出?

我用的是Pelican3.7.1。

EN

回答 2

Stack Overflow用户

发布于 2019-02-18 07:17:13

使用我的Pelican版本(Pelicant 4.0.1,Pelican bootstrap3主题),您可以简单地将图像下推到您的markdown文章模板中,脚本标记如下:

代码语言:javascript
复制
title: title
slug: sluggy
category: stuff
date: 2019-02-12
modified: 2019-02-12

Just some article text with some **markdown** styling.

<script>
<!--
    // This is pure filler that pelican wont execute but does consider when
    // determining the size of the article in the homepage/index overview.
//-->
</script>

<img src="path/to/my/image.png">

More _markdown_ article text.

如果填充足够,图像将不会显示在索引/摘要中。

如果你想防止图像在你的概要中弹出,并且你不想使用summary选项(它不是那么干练),你可以这样做:

代码语言:javascript
复制
title: title
slug: sluggy
category: stuff
date: 2019-02-12
modified: 2019-02-12

This is my article text about how I once altered an image, the result 
was:

<span class="img_point_of_reference"></span>

and I write more text over here.

<script>
    var my_image = document.createElement('IMG')
    my_image.src = "./images/stuff/example_image.png"

    var ref_point = document.getElementsByClassName("img_point_of_reference")[0]
    ref_point.parentNode.insertBefore(my_image, ref_point)
</script>

最后的Javascript只有在文章完全加载时才会执行。

票数 1
EN

Stack Overflow用户

发布于 2017-09-04 03:51:48

尝试使用摘要插件:

这个插件允许简单、可变长度的摘要直接嵌入到你的文章正文中。它引入了两个新的设置: SUMMARY_BEGIN_MARKER和SUMMARY_END_MARKER:字符串,可以直接放入文章中来标记摘要的开始和结束。

https://github.com/getpelican/pelican-plugins/tree/master/summary

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45952092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档