summaryrefslogtreecommitdiff
path: root/examples/blog-multiple-authors/src/pages/posts
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2022-03-28 17:16:06 -0700
committerGravatar GitHub <noreply@github.com> 2022-03-28 17:16:06 -0700
commit4299ab303b0743349fbd01f85340bea61a1c16a8 (patch)
tree7012176c704d4f254fb2a602101fb7f0a01b8450 /examples/blog-multiple-authors/src/pages/posts
parent7d29feace103c0cf7c682634d4359b69338c2a1d (diff)
downloadastro-4299ab303b0743349fbd01f85340bea61a1c16a8.tar.gz
astro-4299ab303b0743349fbd01f85340bea61a1c16a8.tar.zst
astro-4299ab303b0743349fbd01f85340bea61a1c16a8.zip
New Markdown API (#2862)
* Implement new markdown plugin with deferred markdown rendering * feat: switch from `getContent()` fn to `<Content />` API * update types * Update packages/astro/src/@types/astro.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * update types * Create forty-coins-attend.md Co-authored-by: Nate Moore <nate@skypack.dev> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'examples/blog-multiple-authors/src/pages/posts')
-rw-r--r--examples/blog-multiple-authors/src/pages/posts/[...page].astro16
1 files changed, 4 insertions, 12 deletions
diff --git a/examples/blog-multiple-authors/src/pages/posts/[...page].astro b/examples/blog-multiple-authors/src/pages/posts/[...page].astro
index d0f95ce5b..da9b06fc5 100644
--- a/examples/blog-multiple-authors/src/pages/posts/[...page].astro
+++ b/examples/blog-multiple-authors/src/pages/posts/[...page].astro
@@ -6,8 +6,8 @@ import Pagination from '../../components/Pagination.astro';
import authorData from '../../data/authors.json';
export async function getStaticPaths({ paginate, rss }) {
- const allPosts = Astro.fetchContent<MarkdownFrontmatter>('../post/*.md');
- const sortedPosts = allPosts.sort((a, b) => new Date(b.date).valueOf() - new Date(a.date).valueOf());
+ const allPosts = await Astro.glob('../post/*.md');
+ const sortedPosts = allPosts.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf());
// Generate an RSS feed from this collection of posts.
// NOTE: This is disabled by default, since it requires `buildOptions.site` to be set in your "astro.config.mjs" file.
@@ -31,21 +31,13 @@ export async function getStaticPaths({ paginate, rss }) {
let title = 'Don’s Blog';
let description = 'An example blog on Astro';
let canonicalURL = Astro.request.canonicalURL;
-
-// collection
-interface MarkdownFrontmatter {
- date: number;
- description: string;
- title: string;
-}
-
const { page } = Astro.props;
---
<html lang="en">
<head>
<title>{title}</title>
- <MainHead {title} {description} image={page.data[0].image} canonicalURL={canonicalURL.toString()} prev={page.url.prev} next={page.url.next} />
+ <MainHead {title} {description} image={page.data[0].frontmatter.image} canonicalURL={canonicalURL.toString()} prev={page.url.prev} next={page.url.next} />
<style lang="scss">
.title {
@@ -70,7 +62,7 @@ const { page } = Astro.props;
<main class="wrapper">
<h2 class="title">All Posts</h2>
<small class="count">{page.start + 1}–{page.end + 1} of {page.total}</small>
- {page.data.map((post) => <PostPreview post={post} author={authorData[post.author]} />)}
+ {page.data.map((post) => <PostPreview post={post} author={authorData[post.frontmatter.author]} />)}
</main>
<footer>