Skip to content

Commit

Permalink
Improve RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Mar 3, 2024
1 parent 1e693f4 commit 78ba8ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
5 changes: 5 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<link rel="stylesheet" type="text/css" href="/style.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Mali">
<link rel="alternate" type="application/rss+xml" title="{{ config.title }}" href="/feed.xml" />

{% block rss %}
<link rel="alternate" type="application/atom+xml" title="RSS" href="{{ get_url(path="feed.xml",
trailing_slash=false) }}">
{% endblock %}
</head>

<body>
Expand Down
26 changes: 7 additions & 19 deletions templates/feed.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
{# The line above needs to be the first line, otherwise the feed will be invalid #}
{# Spec: https://validator.w3.org/feed/docs/atom.html #}
{% set is_community = taxonomy is defined and taxonomy.name == "tags" and term.name == "community" %}
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<id>{{ config.base_url }}</id>
<title>{{ config.title }}{% if is_community %} - Community{% endif %}</title>
<title type="text">{{ config.title }}{% if is_community %} - Community{% endif %}</title>
<subtitle type="text">{{ config.description }}</subtitle>
<updated>{{ now() | date(format="%+") }}</updated>{# Needs to be ISO8601, https://docs.rs/chrono/0.4.23/chrono/format/strftime/index.html #}
<subtitle>{{ config.description }}</subtitle>
<link rel="self" type="application/rss+xml" href="{{ feed_url | safe }}" />
<link rel="self" type="application/atom+xml" href="{{ feed_url | safe }}" />
<link rel="alternate" type="text/html" href="{{ config.base_url | safe }}" />
<id>{{ config.base_url | safe }}</id>
<author>
<name>{{ config.extra.full_name }}</name>
<uri>{{ config.base_url }}</uri>
Expand All @@ -23,28 +20,19 @@
{% for post in pages %}
<entry>
<id>{{ post.permalink }}</id>
<title type="html">{{ post.title }}</title>
<title type="html"><![CDATA[ {{ post.title }} ]]></title>
<link rel="alternate"
type="text/html"
href="{{ post.permalink | safe }}"
title="{{ post.title }}" />
<summary type="html">
{% if post.summary %}
{{ post.summary | trim | spaceless | escape_xml }}
{% else %}
{{ throw(message="Post is missing a summary. Use <!-- more --> to delimitate the summary.") }}
{% endif %}
</summary>

<published>{{ post.date | date(format="%+")}}</published>
<updated>{{ post.updated | default(value=post.date) | date(format="%+")}}</updated>

<author>
<name>{{ config.extra.full_name }}</name>
<uri>{{ config.base_url }}</uri>
<email>{{ config.extra.email }}</email>
</author>

<updated>{{ post.updated | default(value=post.date) | date(format="%+")}}</updated>
<summary type="html">{% if post.summary %}{{ post.summary | trim | spaceless | escape_xml }}{% else %}{{ throw(message="Post is missing a summary. Use <!-- more --> to delimitate the summary.") }}{% endif %}</summary>
{% if is_community %}
<content type="html">{{ post.content | trim | spaceless | escape_xml | safe }}

Expand Down

0 comments on commit 78ba8ac

Please sign in to comment.