首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jekyll开始*和*结束节选分离器

Jekyll开始*和*结束节选分离器
EN

Stack Overflow用户
提问于 2020-08-12 00:49:22
回答 2查看 292关注 0票数 3

我在和杰基尔写博客。我知道jekyll有一个excerpt_separator,它可以用来指定一个节选的结尾,比如

代码语言:javascript
复制
This is a blog post, click to see more than this
<!-- more -->
This is not in excerpt

然而,我想开始我的每个博客文章的引文,但不包括在节选。有点像

代码语言:javascript
复制
>   “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.

到目前为止,我还没有找到证据证明这是有根据的。

我该怎么做才能做到这一点?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-12 14:12:08

不幸的是,Jekyll在默认情况下并不支持一种指定摘录开始的方法。

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

这是有点凌乱,并打破了页面内容,但它会工作。

代码语言:javascript
复制
---
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.
票数 1
EN

Stack Overflow用户

发布于 2020-08-23 03:22:04

我找到了另一种可行的方法,不应该破坏预期的行为。我发现如果你把引号移到前面,并改变你的布局,你可以让摘录忽略引号。

样本职位:

代码语言:javascript
复制
---
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.

版面部分:

代码语言:javascript
复制
{% if page.quote %}
  <p class="lead">{{ page.quote | markdownify }}</p> 
{% endif %}     
<p class="lead">{{ content }}</p>

这是因为引文不再是帖子内容的一部分。但是,posts布局将在文章内容之前将引号添加到页面布局中。你甚至可以用这种方式引用他们自己的风格属性。这也是如何向不属于内容的页面添加功能(如注释)。

注:如果你想在单行上加一个双空格,你就必须在引号的每一行后面加一个双空格。另外,如果您想让整个文章内容显示在另一个页面上,如果需要的话,您必须手动地包含引号。

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

https://stackoverflow.com/questions/63368224

复制
相关文章

相似问题

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