Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
f7127e2748 | ||
|
2bb8a66943 |
4791
pnpm-lock.yaml
Normal file
4791
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
35
public/rss.xsl
Normal file
35
public/rss.xsl
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="3.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
||||
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
||||
<xsl:template match="/">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<title>
|
||||
RSS Feed | <xsl:value-of select="//title"/>
|
||||
</title>
|
||||
<!-- where is the stylesheet? -->
|
||||
<!-- <link rel="stylesheet" href="/assets/styles.css"/> -->
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
This is an RSS feed. Visit
|
||||
<a href="https://aboutfeeds.com">About Feeds</a>
|
||||
to learn more and get started.
|
||||
</p>
|
||||
<h1>RSS Feed | <xsl:value-of select="//title"/></h1>
|
||||
<xsl:for-each select="//item">
|
||||
<article>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="link"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="title"/>
|
||||
</a>
|
||||
</article>
|
||||
</xsl:for-each>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
|
@ -5,13 +5,28 @@ import { getCollection } from 'astro:content';
|
|||
import Nav from '../components/nav.astro';
|
||||
import '../styles/fonts.css';
|
||||
|
||||
function sortDates(d1: { data: { date: string } }, d2: { data: { date: string } }) {
|
||||
function sortDates(
|
||||
d1: { data: { date: string } },
|
||||
d2: { data: { date: string } }
|
||||
) {
|
||||
const date1 = new Date(d1.data.date),
|
||||
date2 = new Date(d2.data.date);
|
||||
return date2.getTime() - date1.getTime();
|
||||
}
|
||||
|
||||
export const data = await getCollection('posts');
|
||||
|
||||
function parseNumberOfArticles(post: (typeof data)[0]): number {
|
||||
var pos = 0;
|
||||
var count = 0;
|
||||
while (true) {
|
||||
const i = post.body.indexOf('\n- [', pos);
|
||||
if (i < 0) break;
|
||||
pos = i + 1;
|
||||
count += 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
|
@ -39,28 +54,29 @@ export const data = await getCollection('posts');
|
|||
class="grid grid-cols-1 md:grid-cols-2 md:gap-x-16 lg:gap-x-32 gap-y-14"
|
||||
>
|
||||
{
|
||||
data.sort(sortDates).map((post) => (
|
||||
<div class="p-4">
|
||||
<h3 class="font-semibold text-3xl">
|
||||
<a
|
||||
class="hover:underline underline-offset-2 hover:text-primary-500"
|
||||
href={`/posts/${post.slug}`}
|
||||
>
|
||||
{post.data.title}
|
||||
</a>
|
||||
</h3>
|
||||
<div class="mb-2">
|
||||
{format(parseISO(post.data.date), 'dd MMM, yyy')}
|
||||
data.sort(sortDates).map((post) => {
|
||||
const na = parseNumberOfArticles(post);
|
||||
return (
|
||||
<div class="p-4">
|
||||
<h3 class="font-semibold text-3xl">
|
||||
<a
|
||||
class="hover:underline underline-offset-2 hover:text-primary-500"
|
||||
href={`/posts/${post.slug}`}
|
||||
>
|
||||
{post.data.title}
|
||||
</a>
|
||||
</h3>
|
||||
<div class="mb-2 text-sm leading-none mt-1 mb-2">
|
||||
<data title="article count" value={na}>{'┃'.repeat(na)}</data>
|
||||
</div>
|
||||
{post.data.description ?? (
|
||||
<p class="text-lg leading-relaxed mb-4">
|
||||
{post.data.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{post.data.description !== '' ? (
|
||||
<p class="text-lg leading-relaxed mb-4">
|
||||
{post.data.description}
|
||||
</p>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,5 +18,6 @@ export async function GET(context: { site: any; }) {
|
|||
content: sanitizeHtml(parser.render(post.body)),
|
||||
link: `/posts/${post.slug}`,
|
||||
})) as RSSFeedItem[],
|
||||
stylesheet: '/rss.xsl',
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue