Jekyll开始*和*结束摘录分隔符

问题描述

我正在与Jekyll撰写博客。我知道jekyll具有excerpt_separator,可用于指定摘要的结尾,例如

This is a blog post,click to see more than this
<!-- more -->
This is not in excerpt

但是,我想在我的每篇博客文章中都加引号,但不要在摘录中包括该引号。像

>   “There are two ways of constructing a software design: One way is to make it
>   so simple that there are obvIoUsly no deficiencies and the other way is to
>   make it so complicated that there are no obvIoUs deficiencies.” – C.A.R. Hoare

<!-- begin_excerpt -->
This is the excerpt
<!-- end_excerpt -->

Not part of the excerpt.

到目前为止,我一直找不到支持功能的证据。@H_502_15@ 我该怎么做才能做到这一点?

解决方法

不幸的是,默认情况下,Jekyll不支持指定摘录开始的方式。

解决此问题的一种可能方法是在Jekyll的前题中使用excerpt变量,然后直接向其中写入所需的文本,然后在page.excerpt中显示变量的值。页面内容。

这有点混乱,它破坏了页面内容,但是可以正常工作。

---
excerpt: 'This is the excerpt'
---

>   “There are two ways of constructing a software design: One way is to make it
>   so simple that there are obviously no deficiencies and the other way is to
>   make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare

{{ page.excerpt }} // This is the excerpt

Not part of the excerpt.
,

我找到了一种可行的替代方法,不应破坏预期的行为。我发现如果您将引号移到最前面并更改布局,您可以让摘录忽略引号。

示例帖子:

---
title: Test of Quote Post
layout: quotepost
categories: Random
comments: false
quote: |
    Hack the Planet!  
    Hack the Planet!
---
A sample post preceded by a quote.

布局部分:

{% if page.quote %}
  <p class="lead">{{ page.quote | markdownify }}</p> 
{% endif %}     
<p class="lead">{{ content }}</p>

这行得通,因为报价已不再是帖子内容的一部分。但是,帖子布局会将引号添加到帖子内容之前的页面布局中。您甚至可以通过这种方式为引号提供自己的样式属性。这也是向页面添加不属于内容的功能(如评论)的方式。

注意:如果希望引号放在单独的行中,则必须在引号的每一行之后添加一个双精度空格。另外,如果您希望将整个帖子的内容显示在另一页上,则需要时必须手动添加引号。