feat: feed/search/sitemap

This commit is contained in:
Cory Dransfeldt 2024-10-11 19:10:20 -07:00
parent 086cd20788
commit c6d00b2836
No known key found for this signature in database
34 changed files with 198 additions and 535 deletions

View file

@ -1,48 +1,24 @@
{
"version": "https://jsonfeed.org/version/1.1",
"title": "{{ title | escape }}",
"home_page_url": "{{ permalink | absoluteUrl | escape }}",
"feed_url": "{{ permalink | absoluteUrl | escape }}.json",
"description": "{{ globals.site_description | escape }}",
"icon": "https://cdn.coryd.dev{{ globals.avatar | escape }}?class=w200&v={% appVersion %}",
"favicon": "https://cdn.coryd.dev{{ globals.avatar | escape }}?class=w50&v={% appVersion %}",
"authors": [{
"name": "{{ globals.site_name }}",
"url": "{{ globals.url | escape }}",
"avatar": "https://cdn.coryd.dev{{ globals.avatar | escape }}?class=w200&v={% appVersion %}"
}],
"items": [
{%- assign entries = data | normalizeEntries: 20 -%}
{%- for entry in entries -%}
{%- assign summary = entry.content | strip_html | normalize_whitespace | escape -%}
{%- assign utm_parameters = "utm_source=rss&utm_medium=feed&utm_campaign=" | append: utm_campaign -%}
{
"id": "{{ entry.url | encodeAmp | escape }}",
"title": "{{ entry.title | escape }}{% if entry.authors %} via {{ entry.authors.name | escape }}{% endif %}{% if entry.rating %} ({{ entry.rating | escape }}){% endif %}",
{%- if utm_campaign -%}
"url": "{{ entry.url | append: '?' | append: utm_parameters }}",
{%- else -%}
"url": "{{ entry.url | encodeAmp }}",
{%- endif -%}
"content_html": "{{ summary }}",
"summary": "{{ summary }}",
{%- if entry.author -%}
"external_url": "{{ entry.url | encodeAmp | escape }}",
"authors": [{
"name": "{{ entry.author.name | escape }}",
"url": "{{ entry.author.url | escape }}",
"mastodon": "{{ entry.author.mastodon | escape }}",
"rss": "{{ entry.author.feed | escape }}"
}],
{%- endif %}
"date_published": "{{ entry.date | date: '%Y-%m-%dT%H:%M:%S%:z' }}"{%- if entry.tags -%},
"tags": [
{%- for tag in entry.tags -%}
"{{ tag | escape }}"{%- unless forloop.last -%}, {% endunless -%}
{%- endfor -%}
]
{%- endif -%}
}{%- if forloop.last == false -%},{%- endif -%}
{%- endfor -%}
]
"version": "https://jsonfeed.org/version/1",
"title": "{{ title }}",
"home_page_url": "{{ globals.url }}",
"feed_url": "{{ permalink | absoluteUrl }}",
"description": "{{ globals.site_description }}",
"icon": "https://cdn.coryd.dev{{ globals.avatar }}?class=w200",
"author": {
"name": "{{ globals.site_name }}",
"url": "{{ globals.url }}",
"avatar": "https://cdn.coryd.dev{{ globals.avatar }}?class=w200"
},
"items": [
{%- assign entries = data -%}
{%- for entry in entries limit: 20 -%}
{
"id": "{{ entry.feed.url | encodeAmp }}",
"url": "{{ entry.feed.url | encodeAmp }}",
"title": "{{ entry.feed.title }}",
"date_published": "{{ entry.feed.date | stringToRFC3339 }}"
}{%- if forloop.last == false -%},{%- endif -%}
{%- endfor -%}
]
}

View file

@ -3,11 +3,11 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="{{ permalink | absoluteUrl }}" rel="self" type="application/rss+xml" />
{%- assign entries = data | normalizeEntries: 20 -%}
{%- assign entries = data -%}
<title><![CDATA[{{ title }}]]></title>
<description><![CDATA[{{ globals.site_description }}]]></description>
<link>{{ permalink | absoluteUrl }}</link>
<lastBuildDate>{{ updated | stringToRFC822Date }}</lastBuildDate>
<lastBuildDate>{{ 'now' | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>
<image>
<title><![CDATA[{{ title }}]]></title>
<link>{{ permalink | absoluteUrl }}</link>
@ -15,27 +15,28 @@
<width>144</width>
<height>144</height>
</image>
{% for entry in entries -%}
{% for entry in entries limit: 20 -%}
{%- assign entryFeed = entry.feed -%}
{%- assign rating = entry.rating -%}
{%- capture entryTitle -%}
{{ entry.title }}
{%- if entry.authors %} via {{ entry.authors.name }}{%- endif -%}
{{ entryFeed.title }}
{%- if entryFeed.artist and entryFeed.artist.name %} via {{ entryFeed.artist.name }}{%- endif -%}
{%- if rating %} ({{ rating }}){%- endif -%}
{%- endcapture -%}
{%- assign utm_parameters = "utm_source=rss&utm_medium=feed&utm_campaign=" | append: utm_campaign -%}
<item>
<title><![CDATA[{{ entryTitle }}]]></title>
{%- if utm_campaign -%}
<link>{{ entry.url | append: '?' | append: utm_parameters | encodeAmp }}</link>
<link>{{ entryFeed.url | append: '?' | append: utm_parameters | encodeAmp }}</link>
{%- else -%}
<link>{{ entry.url | encodeAmp }}</link>
<link>{{ entryFeed.url | encodeAmp }}</link>
{%- endif -%}
<pubDate>{{ entry.date | stringToRFC822Date }}</pubDate>
<guid isPermaLink="false">{{ entry.url | encodeAmp }}</guid>
{%- if entry.image -%}
<enclosure url="https://cdn.coryd.dev{{ entry.image }}?class=w800" type="image/jpeg" />
<pubDate>{{ entryFeed.date | stringToRFC822Date }}</pubDate>
<guid isPermaLink="false">{{ entryFeed.url | encodeAmp }}</guid>
{%- if entryFeed.image -%}
<enclosure url="https://cdn.coryd.dev{{ entryFeed.image }}?class=w800" type="image/jpeg" />
{%- endif -%}
<description>{{ entry.excerpt | escape }}</description>
<description><![CDATA[{{ entryFeed.description | escape | markdown }}]]></description>
</item>
{%- endfor %}
</channel>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="{{ permalink | absoluteUrl }}" rel="self" type="application/rss+xml" />
{%- assign entries = data -%}
<title><![CDATA[{{ title }}]]></title>
<description><![CDATA[{{ globals.site_description }}]]></description>
<link>{{ permalink | absoluteUrl }}</link>
{% assign firstEntry = entries | first %}
<lastBuildDate>{{ 'now' | date: "%a, %d %b %Y %H:%M:%S %z" }}</lastBuildDate>
<image>
<title><![CDATA[{{ title }}]]></title>
<link>{{ permalink | absoluteUrl }}</link>
<url>{{ "https://cdn.coryd.dev" | append: globals.avatar | append: "?class=w200" }}</url>
<width>144</width>
<height>144</height>
</image>
{% for entry in entries limit: 20 -%}
{%- assign entrySyndication = entry.syndication -%}
<item>
<title><![CDATA[{{ entrySyndication.title }}]]></title>
<link>{{ entrySyndication.url | encodeAmp }}</link>
<pubDate>{{ entrySyndication.date | stringToRFC822Date }}</pubDate>
<guid isPermaLink="false">{{ entrySyndication.url | encodeAmp }}</guid>
<description><![CDATA[{{ entrySyndication.description | escape | markdown }}]]></description>
</item>
{%- endfor %}
</channel>
</rss>