如何将永久链接添加到Jekyll RSS源



我的Jekyll RSS提要中的一些帖子是链接帖子(点击标题后,他们会将阅读器转发到外部源URL)。我在feed.xml中为它们设置了{% if post.link %}液体过滤器。

我想要的是在RSS提要中的链接帖子底部显示"∞永久链接">

我的问题:有没有办法在feed.xml文件中的每个链接帖子的底部显示永久链接?

作为一种变通方法,我可以在帖子内容区域的底部设置一个额外的永久链接,但它也会显示在帖子中,所以我很想知道是否有更直接的方法。

更新:我尝试设置一个单独的Permalink这个:

<a title="Permalink" class="permalink" href="{{ site.domain }}{{ page.url }}">∞ Permalink</a>

如果我把链接放在实际2012-10-18-example-post.md文件的底部,它就可以工作,但当我把它放在模板中时,它无法显示在RSS Feed阅读器中,c.f.:

...
{{ content }}
<a title="Permalink" class="permalink" href="{{ site.domain }}{{ post.url }}">∞ Permalink</a>

有人知道如何将链接附加到内容标签吗?

这是我的feed.xml-如果有帮助的话:

---
layout: none
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.name }}</title>
<description>{{ site.description }}</description>
<link>{{ site.url }}</link>
<atom:link href="{{ site.url }}/feed.links.xml" rel="self" type="application/rss+xml" />
{% for post in site.posts limit:30 %}
{% if post.link %}
<item>
<title>Link:{{ post.title }}</title>
<description>{{ post.content | xml_escape }}</description>
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
<link>{{ post.link | escape }}</link>
<guid isPermaLink="true">{{ post.link }}</guid>
</item>
{% else %}
{% unless post.link %}
<item>
<title>{{ post.title }}</title>
<description>{{ post.content | xml_escape }}</description>
<pubDate>{{ post.date | date: "%a, %d %b %Y %H:%M:%S %z" }}</pubDate>
<link>{{ site.url }}{{ post.url }}</link>
<guid isPermaLink="true">{{ site.url }}{{ post.url }}</guid>
</item>
{% endunless %}
{% endif %}
{% endfor %}
</channel>
</rss>

将其添加到rss文件中相应的<description>标记中。不要忘记,这是一个包含HTML的XML文档,所以您必须对HTML内容进行XML转义:

<description>
{{ post.content | xml_escape }}
&lt;a title=&quot;Permalink&quot; class=&quot;permalink&quot; href=&quot;{{ site.domain | xml_escape }}{{ post.url | xml_escape }}&quot;&gt;
∞ Permalink
&lt;/a&gt;
</description>

最新更新