从页面中删除预告片
Remove teaser from pages
我正在用 Hakyll 制作一个网站。我成功地创建了一个 RSS 提要,显示每个 post 由 <!--more-->
分隔的预告片部分。
我的问题是这个预告部分显示在这些 post 的完整(模板)页面中。我只希望在 <!--more-->
之后而不是之前。
---
title: My Post
author: JeanJouX
date: 2016-09-06
tags: Haskell
---
The teaser of my post to be shown in the RSS feed. Not in the full page.
<!--more-->
The rest of the post to be shown in the full page of my website
可以用 Hakyll 做到这一点吗?
我认为 Hakyll 中没有内置的方法可以做到这一点。
据我所知,您有两个选择:
编写一个通道,在将预告片呈现在自己的页面上之前从文档中剥离预告片
将预告片保留在实际页面中,但使用 CSS 隐藏它
第一个选项可能更好,但需要考虑字符串操作和 Hakyll 编译器。如果您想从一个地方开始,请查看 teaserFieldWithSeparator
which uses the needlePrefix
function from Hakyll.Core.Util.String
的实现以从文档正文中提取预告片。您必须执行相反的操作:提取所有内容 但 预告片。
如果你真的采用这种方法,你可以将它贡献回 Hakyll,为将来想要做同样事情的人节省精力。
另一个选项更复杂但更容易。您可以将所有预告片包装在 div 中,其中包含一些 CSS class:
<div class="teaser">
Some text.
</div>
<!--more-->
然后,在您的页面模板中,添加 CSS 隐藏预告片的规则:
.teaser {
display : none;
}
文本仍在页面的 HTML 中,因此这不是 理想的 解决方案,但您无需编写任何 Hakyll 代码即可使其工作。
如果您将这个预告文本放在一个单独的元数据字段中,也许会更容易?喜欢
---
title: My Post
author: JeanJouX
date: 2016-09-06
tags: Haskell
description: The teaser of my post to be shown in the RSS feed. Not in the full page.
---
The rest of the post to be shown in the full page of my website
那你就不需要再teaserField
了。您已经在 $description$
中拥有您需要的所有内容,您可以在 rss、html 元标记中、任何地方使用它。
我正在用 Hakyll 制作一个网站。我成功地创建了一个 RSS 提要,显示每个 post 由 <!--more-->
分隔的预告片部分。
我的问题是这个预告部分显示在这些 post 的完整(模板)页面中。我只希望在 <!--more-->
之后而不是之前。
---
title: My Post
author: JeanJouX
date: 2016-09-06
tags: Haskell
---
The teaser of my post to be shown in the RSS feed. Not in the full page.
<!--more-->
The rest of the post to be shown in the full page of my website
可以用 Hakyll 做到这一点吗?
我认为 Hakyll 中没有内置的方法可以做到这一点。
据我所知,您有两个选择:
编写一个通道,在将预告片呈现在自己的页面上之前从文档中剥离预告片
将预告片保留在实际页面中,但使用 CSS 隐藏它
第一个选项可能更好,但需要考虑字符串操作和 Hakyll 编译器。如果您想从一个地方开始,请查看 teaserFieldWithSeparator
which uses the needlePrefix
function from Hakyll.Core.Util.String
的实现以从文档正文中提取预告片。您必须执行相反的操作:提取所有内容 但 预告片。
如果你真的采用这种方法,你可以将它贡献回 Hakyll,为将来想要做同样事情的人节省精力。
另一个选项更复杂但更容易。您可以将所有预告片包装在 div 中,其中包含一些 CSS class:
<div class="teaser">
Some text.
</div>
<!--more-->
然后,在您的页面模板中,添加 CSS 隐藏预告片的规则:
.teaser {
display : none;
}
文本仍在页面的 HTML 中,因此这不是 理想的 解决方案,但您无需编写任何 Hakyll 代码即可使其工作。
如果您将这个预告文本放在一个单独的元数据字段中,也许会更容易?喜欢
---
title: My Post
author: JeanJouX
date: 2016-09-06
tags: Haskell
description: The teaser of my post to be shown in the RSS feed. Not in the full page.
---
The rest of the post to be shown in the full page of my website
那你就不需要再teaserField
了。您已经在 $description$
中拥有您需要的所有内容,您可以在 rss、html 元标记中、任何地方使用它。