summaryrefslogtreecommitdiff
path: root/examples/blog/src
diff options
context:
space:
mode:
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/