summaryrefslogtreecommitdiff
path: root/examples/blog/src
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/src
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/src')
-rw-r--r--examples/blog/src/components/BlogPostPreview.astro6
-rw-r--r--examples/blog/src/pages/index.astro8
2 files changed, 5 insertions, 9 deletions
diff --git a/examples/blog/src/components/BlogPostPreview.astro b/examples/blog/src/components/BlogPostPreview.astro
index 4841d3a65..f935ff8b2 100644
--- a/examples/blog/src/components/BlogPostPreview.astro
+++ b/examples/blog/src/components/BlogPostPreview.astro
@@ -8,10 +8,10 @@ const { post } = Astro.props;
<article class="post-preview">
<header>
- <p class="publish-date">{post.publishDate}</p>
- <a href={post.url}><h1 class="title">{post.title}</h1></a>
+ <p class="publish-date">{post.frontmatter.publishDate}</p>
+ <a href={post.url}><h1 class="title">{post.frontmatter.title}</h1></a>
</header>
- <p>{post.description}</p>
+ <p>{post.frontmatter.description}</p>
<a href={post.url}>Read more</a>
</article>
diff --git a/examples/blog/src/pages/index.astro b/examples/blog/src/pages/index.astro
index c7bc3ea32..1e1264533 100644
--- a/examples/blog/src/pages/index.astro
+++ b/examples/blog/src/pages/index.astro
@@ -4,10 +4,6 @@ import BaseHead from '../components/BaseHead.astro';
import BlogHeader from '../components/BlogHeader.astro';
import BlogPostPreview from '../components/BlogPostPreview.astro';
-interface MarkdownFrontmatter {
- publishDate: number;
-}
-
// Component Script:
// You can write any JavaScript/TypeScript that you'd like here.
// It will run during the build, but never in the browser.
@@ -18,8 +14,8 @@ let permalink = 'https://example.com/';
// Data Fetching: List all Markdown posts in the repo.
-let allPosts = await Astro.fetchContent('./posts/*.md');
-allPosts = allPosts.sort((a, b) => new Date(b.publishDate).valueOf() - new Date(a.publishDate).valueOf());
+let allPosts = await Astro.glob('./posts/*.md');
+allPosts = allPosts.sort((a, b) => new Date(b.frontmatter.publishDate).valueOf() - new Date(a.frontmatter.publishDate).valueOf());
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/