diff options
author | 2022-03-28 17:16:06 -0700 | |
---|---|---|
committer | 2022-03-28 17:16:06 -0700 | |
commit | 4299ab303b0743349fbd01f85340bea61a1c16a8 (patch) | |
tree | 7012176c704d4f254fb2a602101fb7f0a01b8450 /examples/blog-multiple-authors/src/pages/index.astro | |
parent | 7d29feace103c0cf7c682634d4359b69338c2a1d (diff) | |
download | astro-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/index.astro')
-rw-r--r-- | examples/blog-multiple-authors/src/pages/index.astro | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/examples/blog-multiple-authors/src/pages/index.astro b/examples/blog-multiple-authors/src/pages/index.astro index 8ad01c190..518424b99 100644 --- a/examples/blog-multiple-authors/src/pages/index.astro +++ b/examples/blog-multiple-authors/src/pages/index.astro @@ -6,12 +6,6 @@ import PostPreview from '../components/PostPreview.astro'; import Pagination from '../components/Pagination.astro'; import authorData from '../data/authors.json'; -interface MarkdownFrontmatter { - date: number; - image: string; - author: string; -} - // Component Script: // You can write any JavaScript/TypeScript that you'd like here. // It will run during the build, but never in the browser. @@ -21,10 +15,9 @@ let description = 'An example blog on Astro'; let canonicalURL = Astro.request.canonicalURL; // Data Fetching: List all Markdown posts in the repo. -let allPosts = Astro.fetchContent<MarkdownFrontmatter>('./post/*.md'); -allPosts.sort((a, b) => new Date(b.date).valueOf() - new Date(a.date).valueOf()); +let allPosts = await Astro.glob('./post/*.md'); +allPosts.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf()); let firstPage = allPosts.slice(0, 2); - // Full Astro Component Syntax: // https://docs.astro.build/core-concepts/astro-components/ --- @@ -32,14 +25,14 @@ let firstPage = allPosts.slice(0, 2); <html lang="en"> <head> <title>{title}</title> - <MainHead {title} {description} image={allPosts[0].image} {canonicalURL} /> + <MainHead {title} {description} image={allPosts[0].frontmatter.image} {canonicalURL} /> </head> <body> <Nav {title} /> <main class="wrapper"> - {allPosts.map((post) => <PostPreview post={post} author={authorData[post.author]} />)} + {allPosts.map((post) => <PostPreview post={post} author={authorData[post.frontmatter.author]} />)} </main> <footer> |