-
Notifications
You must be signed in to change notification settings - Fork 0
/
[...slug].astro
61 lines (56 loc) · 1.44 KB
/
[...slug].astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
import { type CollectionEntry, getCollection } from "astro:content";
import BlogPost from "../../layouts/BlogPost.astro";
import { type Configuration, type Result, run } from "webring";
export async function getStaticPaths() {
const posts = await getCollection("blog");
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
}
type Props = CollectionEntry<"blog">;
const post = Astro.props;
const { Content } = await post.render();
export const config: Configuration = {
sources: [
{
url: "https://drewdevault.com/blog/index.xml",
title: "Drew DeVault",
},
{
url: "https://danluu.com/atom.xml",
title: "Dan Luu",
},
{
url: "https://jakelazaroff.com/rss.xml",
title: "Jake Lazaroff",
},
],
// the output will return the three most recent posts from the above sources
number: 3,
// the output will return santized HTML truncated to 300 characters
truncate: 300,
// if this is defined, we'll cache the results
cache: {
// the file to use as a cache
cache_file: "webring.json",
// how long the cache should remain valid for
cache_duration_minutes: 60,
},
};
export const result: Result = await run(config);
---
<BlogPost {...post.data}>
<Content />
<h2>Posts from blogs I read</h2>
<ul>
{
result.map((post) => (
<li>
<a href={post.url}>{post.title}</a>
</li>
))
}
</ul>
</BlogPost>