定制文章内容xml模板

This commit is contained in:
结发受长生
2019-07-01 14:48:12 +08:00
parent 2b635d6783
commit da0530d37a
6 changed files with 56 additions and 17 deletions
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<search>
{% for post in posts.toArray() %}
{% if post.indexing == undefined or post.indexing %}
<entry>
<title>{{ post.title }}</title>
<link href="{{ root + post.path }}"/>
<path>{{ post.path }}</path>
{% if post.categories and post.categories.length>0 %}
<categories>
{% for cate in post.categories.toArray() %}
<category> {{ cate.name }} </category>
{% endfor %}
</categories>
{% endif %}
{% if post.tags and post.tags.length>0 %}
<tags>
{% for tag in post.tags.toArray() %}
<tag> {{ tag.name }} </tag>
{% endfor %}
</tags>
{% endif %}
{% if post.date %}
<date>{{ +post.date }}</date>
{% endif %}
<content type="html"><![CDATA[{{ post.content | noControlChars | safe }}]]></content>
</entry>
{% endif %}
{% endfor %}
</search>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in posts %}
<url>
<loc>{{ post.permalink | uriencode }}</loc>
{% if post.updated %}
<lastmod>{{ post.updated.toISOString() }}</lastmod>
{% elif post.date %}
<lastmod>{{ post.date.toISOString() }}</lastmod>
{% endif %}
</url>
{% endfor %}
</urlset>