Skip to content

Commit

Permalink
RSS feed style and tweaks
Browse files Browse the repository at this point in the history
- Replace the RSS/atom feed from `jekyll-feed` with a manual template
  found on GitHub: <https://gist.github.com/andrewstiefel/57a0a400aa2deb6c9fe18c6da4e16e0f>
- Add some light CSS to match
  • Loading branch information
maxkapur committed Feb 25, 2024
1 parent b436629 commit f921cbe
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 3 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ gem "minima", "~> 2.5"

# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.15"
gem "jekyll-redirect-from", "~> 0.16"
end

Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ PLATFORMS

DEPENDENCIES
jekyll (~> 4.3)
jekyll-feed (~> 0.15)
jekyll-redirect-from (~> 0.16)
json (~> 2.7)
minima (~> 2.5)
Expand Down
1 change: 0 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ youtube_username: maxkapur
theme: minima
show_excerpts: true # on homepage
plugins:
- jekyll-feed
- jekyll-redirect-from
# - jekyll-paginate
# paginate: 2
Expand Down
34 changes: 34 additions & 0 deletions feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
---

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/feed.xsl" type="text/xsl"?>
<!--
Based on
https://gist.github.com/andrewstiefel/57a0a400aa2deb6c9fe18c6da4e16e0f
-->
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.title }}</title>
<link href="{{ site.url }}{{ site.baseurl }}/feed.xml" rel="self" />
<link href="{{ site.url }}{{ site.baseurl }}/" rel="alternate" />
<subtitle>{{ site.description }}</subtitle>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<author>
<name>{{ site.author.name }}</name>
<email>{{ site.author.email }}</email>
</author>
<rights type="text">Creative Commons CC BY-SA 4.0 license</rights>
{% for post in site.posts %}
<entry>
<title>{{ post.title }}</title>
<link rel="alternate" href="{{ site.url }}{{ post.url }}" />
<updated>{{ post.date | date_to_xmlschema }}</updated>
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
<updated-readable>{{ post.date | date: date_format }}</updated-readable>
<id>{{ site.url }}{{ site.baseurl }}{{ post.id }}</id>
<summary>{{ post.excerpt }}</summary>
<content type="html">{{ post.content | xml_escape }}</content>
</entry>
{% endfor %}
</feed>
84 changes: 84 additions & 0 deletions feed.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!--
Based on
https://gist.github.com/andrewstiefel/57a0a400aa2deb6c9fe18c6da4e16e0f
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
exclude-result-prefixes="atom"
>
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title><xsl:value-of select="atom:feed/atom:title" /> | RSS</title>
<link rel="stylesheet" href="/assets/main.css" />
<style type="text/css">
body.feed {
display: flex;
gap: 40px;
padding: 40px 0;
}
</style>

<!-- Favicon -->
<link rel="apple-touch-icon" sizes="180x180" href="/assets/images/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/assets/images/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/assets/images/favicon-16x16.png" />
<link rel="manifest" href="/assets/images/site.webmanifest" />
<link rel="mask-icon" href="/assets/images/safari-pinned-tab.svg" color="#008000" />
<link rel="shortcut icon" href="/assets/images/favicon.ico" />
<meta name="msapplication-TileColor" content="#ffc40d" />
<meta name="msapplication-config" content="/assets/images/browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
</head>

<body class="feed">
<header>
<div class="wrapper">
<xsl:apply-templates select="atom:feed" />
</div>
</header>
<main>
<div class="wrapper">
<ul>
<xsl:apply-templates select="atom:feed/atom:entry" />
</ul>
</div>
</main>
</body>
</html>
</xsl:template>

<xsl:template match="atom:feed">
<h1>Web feed preview</h1>

<p>This is a web feed, also known as an RSS feed, for the <a>
<xsl:attribute name="href">
<xsl:value-of select="atom:link[@rel='alternate']/@href" />
</xsl:attribute>
<xsl:value-of select="atom:title" />
</a> blog. You can subscribe by copying the URL from the
address bar into your newsreader app.</p><p>Visit <a href="https://aboutfeeds.com/">About
Feeds</a> to learn more about newsreaders.</p>
</xsl:template>

<xsl:template match="atom:entry">
<li>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="atom:id" />
</xsl:attribute>
<xsl:value-of select="atom:title" />
</a>
<span class="post-meta"> (<xsl:value-of select="atom:updated-readable" />)</span>
<!--
To incorporate summaries or excerpts (see feed.xml):
<xsl:value-of select="atom:summary" disable-output-escaping="no" />
-->
</li>
</xsl:template>
</xsl:stylesheet>

0 comments on commit f921cbe

Please sign in to comment.