mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: add XSL stylesheet for feeds and fix sorting order
This commit is contained in:
75
public/rss.xsl
Normal file
75
public/rss.xsl
Normal file
File diff suppressed because one or more lines are too long
@@ -2,10 +2,11 @@
|
|||||||
import { site } from '../data/site';
|
import { site } from '../data/site';
|
||||||
import { dateToISO } from '../utils';
|
import { dateToISO } from '../utils';
|
||||||
|
|
||||||
import { mapping } from '../mdx-components';
|
import { rssMapping } from '../mdx-components';
|
||||||
|
|
||||||
const { allPosts } = Astro.props;
|
const { allPosts } = Astro.props;
|
||||||
const rssHeaderXml = `<?xml version="1.0" encoding="UTF-8"?>
|
const rssHeaderXml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?xml-stylesheet href="/rss.xsl" type="text/xsl"?>
|
||||||
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
||||||
<channel>
|
<channel>
|
||||||
<title>${site.title}</title>
|
<title>${site.title}</title>
|
||||||
@@ -22,14 +23,14 @@ const rssFooterXml = ` </channel>
|
|||||||
<>
|
<>
|
||||||
<Fragment
|
<Fragment
|
||||||
set:html={` <item>
|
set:html={` <item>
|
||||||
<title>${post.frontmatter.title}</title>
|
<title>${post.frontmatter.title.replace('&', '&')}</title>
|
||||||
<link>${`${site.url}/${post.frontmatter.slug}/`}</link>
|
<link>${`${site.url}/${post.frontmatter.slug}/`}</link>
|
||||||
<guid>${`${site.url}/${post.frontmatter.slug}/`}</guid>
|
<guid>${`${site.url}/${post.frontmatter.slug}/`}</guid>
|
||||||
<description><![CDATA[${post.frontmatter.description}]]></description>
|
<description><![CDATA[${post.frontmatter.description}]]></description>
|
||||||
<pubDate>${dateToISO(post.frontmatter.date)}</pubDate>
|
<pubDate>${dateToISO(post.frontmatter.date)}</pubDate>
|
||||||
<content:encoded><![CDATA[`}
|
<content:encoded><![CDATA[`}
|
||||||
/>
|
/>
|
||||||
<post.Content components={mapping} />
|
<post.Content components={rssMapping} />
|
||||||
<Fragment
|
<Fragment
|
||||||
set:html={`]]></content:encoded>
|
set:html={`]]></content:encoded>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -79,3 +79,32 @@ export const mapping = {
|
|||||||
Verse,
|
Verse,
|
||||||
YouTube,
|
YouTube,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mapping for RSS feed to reduce the size of the feed
|
||||||
|
export const rssMapping = {
|
||||||
|
AffiliateLink,
|
||||||
|
AmazonBook,
|
||||||
|
Banner,
|
||||||
|
Blockquote,
|
||||||
|
Book,
|
||||||
|
Bookshelf,
|
||||||
|
ColorStack,
|
||||||
|
ColorSwatch,
|
||||||
|
DisplayBox,
|
||||||
|
DownloadLink,
|
||||||
|
EmailLink,
|
||||||
|
Figure,
|
||||||
|
Flag,
|
||||||
|
Image,
|
||||||
|
MarkdownImage,
|
||||||
|
MoreLink,
|
||||||
|
NetflixFlag,
|
||||||
|
OdyseeVideo,
|
||||||
|
Picture,
|
||||||
|
PrimeVideoFlag,
|
||||||
|
ProjectIntro,
|
||||||
|
Pullquote,
|
||||||
|
ThemeBox,
|
||||||
|
Verse,
|
||||||
|
YouTube,
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ import rss from '@astrojs/rss';
|
|||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
import { site } from '../data/site';
|
import { site } from '../data/site';
|
||||||
|
import { sortBySortKey } from '../utils';
|
||||||
|
|
||||||
export async function get(context) {
|
export async function get(context) {
|
||||||
const aiArt = await getCollection('ai-art');
|
const aiArt = await getCollection('ai-art');
|
||||||
|
aiArt.sort(sortBySortKey);
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
|
stylesheet: '/rss.xsl',
|
||||||
title: `${site.title} (AI Art)`,
|
title: `${site.title} (AI Art)`,
|
||||||
description: 'This is a collection of AI art pieces I’ve created with Stable Diffusion.',
|
description: 'This is a collection of AI art pieces I’ve created with Stable Diffusion.',
|
||||||
site: context.site,
|
site: context.site,
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ import rss from '@astrojs/rss';
|
|||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
import { site } from '../data/site';
|
import { site } from '../data/site';
|
||||||
|
import { sortByDate } from '../utils';
|
||||||
|
|
||||||
export async function get(context) {
|
export async function get(context) {
|
||||||
const haiku = await getCollection('haiku');
|
const haiku = await getCollection('haiku');
|
||||||
|
haiku.sort(sortByDate);
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
|
stylesheet: '/rss.xsl',
|
||||||
title: `${site.title} (Haiku)`,
|
title: `${site.title} (Haiku)`,
|
||||||
description: 'This is an ever-growing collection of Haiku I have written.',
|
description: 'This is an ever-growing collection of Haiku I have written.',
|
||||||
site: context.site,
|
site: context.site,
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ import rss from '@astrojs/rss';
|
|||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
import { site } from '../data/site';
|
import { site } from '../data/site';
|
||||||
|
import { sortBySortKey } from '../utils';
|
||||||
|
|
||||||
export async function get(context) {
|
export async function get(context) {
|
||||||
const sketchnotes = await getCollection('sketchnotes');
|
const sketchnotes = await getCollection('sketchnotes');
|
||||||
|
sketchnotes.sort(sortBySortKey).reverse();
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
|
stylesheet: '/rss.xsl',
|
||||||
title: `${site.title} (Sketchnotes)`,
|
title: `${site.title} (Sketchnotes)`,
|
||||||
description: 'This is a collection of Sketchnotes I’ve drawn.',
|
description: 'This is a collection of Sketchnotes I’ve drawn.',
|
||||||
site: context.site,
|
site: context.site,
|
||||||
|
|||||||
Reference in New Issue
Block a user