Jekyll 如何替换最后一个<;p>;杰基尔标签
在我的index.html页面中,我想在post.extract之后附加“…”。理想的方法是使用codeJekyll 如何替换最后一个<;p>;杰基尔标签,jekyll,Jekyll,在我的index.html页面中,我想在post.extract之后附加“…”。理想的方法是使用code{{post.extract | replace_last:'','..'}},但是过滤器replace_last似乎没有定义。那么我怎样才能在杰基尔做到这一点呢?谢谢。在我看来,更好的方法是CSS: .excerpt p:last-child::after { content: '..'; } 这将在摘录div中的psuedo元素之后的最后一段中添加“.” <div clas
{{post.extract | replace_last:'','..'}}
,但是过滤器replace_last
似乎没有定义。那么我怎样才能在杰基尔做到这一点呢?谢谢。在我看来,更好的方法是CSS:
.excerpt p:last-child::after {
content: '..';
}
这将在摘录div
中的psuedo元素之后的最后一段中添加“.”
<div class="excerpt">
<p>Normal paragraph.</p>
<p>Paragraph with trailing ellipsis.</p>
</div>
正常段落
带有尾随省略号的段落
如果需要使用Jekyll执行此操作,可以使用切片
过滤器切断尾随的
,并使用附加
过滤器将'…'
添加到末尾。如果你的摘录没有以段落结尾,这将不起作用。我更喜欢从post.extract
中去掉p标记,然后附加“…”。
这样,我们甚至可以在p
中添加“阅读更多”链接
<p>
{{ post.excerpt | strip_html | append: "..." }}
{% if post.excerpt != post.content %}
<a href="{{ post.url | prepend: site.baseurl }}"> >></a>
{% endif %}
</p>
{{post.extract | strip_html | append:“…”}
{%if post.extracpt!=post.content%}
{%endif%}
我找到了一个解决方法,可以通过“阅读更多”链接实现省略号。truncate
过滤器和设置extract_separator
都有缺点,但是,通过split
自己实现很简单。在您的index.html
中使用此选项,您可以在其中迭代帖子:
{{ post.content | split:'<!--read more-->' | first | append: "…"}} <a href="{{ site.baseurl }}{{ post.url }}">Read more</a>
{{post.content | split:''first | append:“…”}
你只需要把
放在你的博客文章中你想让它被一个“…阅读更多”的链接取代的地方。替换\u last
在中不存在。我知道,有没有其他办法解决我的问题?你的摘录有多个段落吗?您想让“…”与摘录的最后一行在同一行,还是在那之后?是否要在“…”和文本之间留空格?1.是2.同一行3.否。谢谢你想在摘录中保留多个段落吗?