Style dat RSS feed
All checks were successful
Build and copy to prod / build-and-copy (push) Successful in 1m51s

This commit is contained in:
Lewis Dale 2024-04-11 07:14:06 +01:00
parent 1584068b59
commit aa862e08ac
7 changed files with 172 additions and 0 deletions

View File

@ -8,6 +8,7 @@
} }
--- ---
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/atom.xslt" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.site.url }}"> <feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.site.url }}">
<title>{{ metadata.site.name }}</title> <title>{{ metadata.site.name }}</title>
<subtitle>{{ metadata.site.description }}</subtitle> <subtitle>{{ metadata.site.description }}</subtitle>

View File

@ -6,6 +6,7 @@ eleventyImport:
- posts - posts
--- ---
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/rss.xslt" type="text/xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:base="{{ metadata.site.url }}" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:base="{{ metadata.site.url }}" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ metadata.site.name }}</title> <title>{{ metadata.site.name }}</title>

82
src/feeds/styles/atom.njk Normal file
View File

@ -0,0 +1,82 @@
---
permalink: "/atom.xslt"
eleventyExcludeFromCollections: true
---
<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>Web Feed • <xsl:value-of select="atom:feed/atom:title"/></title>
<style type="text/css">
body{max-width:768px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:16px;line-height:1.5em}section{margin:30px 15px}h1{font-size:2em;margin:.67em 0;line-height:1.125em}h2{border-bottom:1px solid #eaecef;padding-bottom:.3em}.alert{background:#fff5b1;padding:4px 12px;margin:0 -12px}a{text-decoration:none}.entry h3{margin-bottom:0}.entry p{margin:4px 0}
</style>
</head>
<body>
<section>
<div class="alert">
<p><strong>This is a web feed</strong>, also known as an RSS feed. <strong>Subscribe</strong> by copying the URL from the address bar into your newsreader app.</p>
</div>
</section>
<section>
<xsl:apply-templates select="atom:feed" />
</section>
<section>
<h2>Recent Items</h2>
<xsl:apply-templates select="atom:feed/atom:entry" />
</section>
</body>
</html>
</xsl:template>
<xsl:template match="atom:feed">
<h1><xsl:value-of select="atom:title"/>'s Web Feed Preview</h1>
<p>This RSS feed provides the latest posts from <xsl:value-of select="atom:title"/>'s blog.
<a class="head_link" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="atom:link[@rel='alternate']/@href"/>
</xsl:attribute>
Visit Website &#x2192;
</a>
</p>
<h2>What is an RSS feed?</h2>
<p>An RSS feed is a data format that contains the latest content from a website, blog, or podcast. You can use feeds to <strong>subscribe</strong> to websites and get the <strong>latest content in one place</strong>.</p>
<ul>
<li><strong>Feeds put you in control.</strong> Unlike social media apps, there is no algorithm deciding what you see or read. You always get the latest content from the creators you care about.</li>
<li><strong>Feed are private by design.</strong> No one owns web feeds, so no one is harvesting your personal information and profiting by selling it to advertisers.</li>
<li><strong>Feeds are spam-proof.</strong> Had enough? Easy, just unsubscribe from the feed.</li>
</ul>
<p>All you need to do to get started is to add the URL (web address) for this feed to a special app called a newsreader. Visit <a href="https://aboutfeeds.com/">About Feeds</a> to get started with newsreaders and subscribing. Its free. </p>
</xsl:template>
<xsl:template match="atom:entry">
<div class="entry">
<h3>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="atom:id"/>
</xsl:attribute>
<xsl:value-of select="atom:title"/>
</a>
</h3>
<p>
<xsl:value-of select="atom:summary" disable-output-escaping="yes" />
</p>
<small>
Published: <xsl:value-of select="atom:updated" />
</small>
</div>
</xsl:template>
</xsl:stylesheet>

83
src/feeds/styles/rss.njk Normal file
View File

@ -0,0 +1,83 @@
---
permalink: "/rss.xslt"
eleventyExcludeFromCollections: true
---
<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>Web Feed • <xsl:value-of select="rss/channel/title"/></title>
<style type="text/css">
body{
max-width:768px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:16px;line-height:1.5em}section{margin:30px 15px}h1{font-size:2em;margin:.67em 0;line-height:1.125em}h2{border-bottom:1px solid #eaecef;padding-bottom:.3em}.alert{background:#fff5b1;padding:4px 12px;margin:0 -12px}a{text-decoration:none}.entry h3{margin-bottom:0}.entry p{margin:4px 0} img,picture{max-width:100%;height:auto;width:auto;} pre{max-width:100%;overflow-x:auto;}
</style>
</head>
<body>
<section>
<div class="alert">
<p><strong>This is a web feed</strong>, also known as an RSS feed. <strong>Subscribe</strong> by copying the URL from the address bar into your newsreader app.</p>
</div>
</section>
<section>
<xsl:apply-templates select="rss/channel" />
</section>
<section>
<h2>Recent Items</h2>
<xsl:apply-templates select="rss/channel/item" />
</section>
</body>
</html>
</xsl:template>
<xsl:template match="ch">
<h1><xsl:value-of select="rss/channel/title"/>'s Web Feed Preview</h1>
<p>This RSS feed provides the latest posts from <xsl:value-of select="rss/channel/title"/>'s blog.
<a class="head_link" target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="atom:link[@rel='alternate']/@href"/>
</xsl:attribute>
Visit Website &#x2192;
</a>
</p>
<h2>What is an RSS feed?</h2>
<p>An RSS feed is a data format that contains the latest content from a website, blog, or podcast. You can use feeds to <strong>subscribe</strong> to websites and get the <strong>latest content in one place</strong>.</p>
<ul>
<li><strong>Feeds put you in control.</strong> Unlike social media apps, there is no algorithm deciding what you see or read. You always get the latest content from the creators you care about.</li>
<li><strong>Feed are private by design.</strong> No one owns web feeds, so no one is harvesting your personal information and profiting by selling it to advertisers.</li>
<li><strong>Feeds are spam-proof.</strong> Had enough? Easy, just unsubscribe from the feed.</li>
</ul>
<p>All you need to do to get started is to add the URL (web address) for this feed to a special app called a newsreader. Visit <a href="https://aboutfeeds.com/">About Feeds</a> to get started with newsreaders and subscribing. Its free. </p>
</xsl:template>
<xsl:template match="rss/channel/item">
<div class="entry">
<h3>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="guid"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</h3>
<p>
<xsl:value-of select="description" disable-output-escaping="yes" />
</p>
<small>
Published: <xsl:value-of select="pubDate" />
</small>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -5,10 +5,12 @@ pagination:
alias: tag alias: tag
eleventyComputed: eleventyComputed:
permalink: "/post/tag/{{ tag }}/atom.xml" permalink: "/post/tag/{{ tag }}/atom.xml"
eleventyExcludeFromCollections: true
eleventyImport: eleventyImport:
collections: ["posts", "tags"] collections: ["posts", "tags"]
--- ---
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/atom.xslt" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.site.url }}"> <feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ metadata.site.url }}">
<title>{{ metadata.site.name }}</title> <title>{{ metadata.site.name }}</title>
<subtitle>Posts tagged #{{ tag }}</subtitle> <subtitle>Posts tagged #{{ tag }}</subtitle>

View File

@ -5,6 +5,7 @@ pagination:
alias: tag alias: tag
eleventyComputed: eleventyComputed:
permalink: "/post/tag/{{ tag }}/feed.json" permalink: "/post/tag/{{ tag }}/feed.json"
eleventyExcludeFromCollections: true
eleventyImport: eleventyImport:
collections: ["posts", "tags"] collections: ["posts", "tags"]
--- ---

View File

@ -5,10 +5,12 @@ pagination:
alias: tag alias: tag
eleventyComputed: eleventyComputed:
permalink: "/post/tag/{{ tag }}/rss.xml" permalink: "/post/tag/{{ tag }}/rss.xml"
eleventyExcludeFromCollections: true
eleventyImport: eleventyImport:
collections: ["posts", "tags"] collections: ["posts", "tags"]
--- ---
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/rss.xslt" type="text/xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:base="{{ metadata.site.url }}" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:base="{{ metadata.site.url }}" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ metadata.site.name }}</title> <title>{{ metadata.site.name }}</title>