blob: ebb20705d52f124b0d69eb5119f27a1cd58c89a4 (
plain) (
blame)
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
|
---
import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav.astro';
import PostPreview from '../components/PostPreview.astro';
import Pagination from '../components/Pagination.astro';
// page
let title = 'Muppet Blog: Home';
let description = 'An example blog on Astro';
// collection
import authorData from '../data/authors.json';
export let collection: any;
export async function createCollection() {
return {
async data() {
let allPosts = Astro.fetchContent('./post/*.md');
allPosts.sort((a, b) => new Date(b.date) - new Date(a.date));
return allPosts;
},
pageSize: 3,
rss: {
title: 'Muppet Blog',
description: 'An example blog on Astro',
customData: `<language>en-us</language>`,
item: (item) => ({
title: item.title,
description: item.description,
link: item.url,
pubDate: item.date,
}),
}
};
}
---
<html>
<head>
<title>{title}</title>
<MainHead title={title} description={description} />
<link rel="canonical" href={'https://mysite.dev' + collection.url.current} />
{collection.url.next && <link rel="next" href={'https://mysite.dev' + collection.url.next} />}
{collection.url.prev && <link rel="prev" href={'https://mysite.dev' + collection.url.prev} />}
</head>
<body>
<Nav />
<main class="wrapper">
<h1>All Posts</h1>
<small>{collection.start + 1}–{collection.end + 1} of {collection.total}</small><br />
{collection.data.map((post) => <PostPreview post={post} author={authorData[post.author]} />)}
</main>
<footer>
<Pagination prevUrl={collection.url.prev} nextUrl={collection.url.next} />
</footer>
</body>
</html>
|