diff options
Diffstat (limited to 'examples/blog')
-rw-r--r-- | examples/blog/src/components/BlogPost.astro | 1 | ||||
-rw-r--r-- | examples/blog/src/pages/index.astro | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/examples/blog/src/components/BlogPost.astro b/examples/blog/src/components/BlogPost.astro index 65eed099d..e6a838404 100644 --- a/examples/blog/src/components/BlogPost.astro +++ b/examples/blog/src/components/BlogPost.astro @@ -23,6 +23,7 @@ const { title, author, publishDate, heroImage, alt } = Astro.props; <main> <slot /> </main> + </div> </article> </div> diff --git a/examples/blog/src/pages/index.astro b/examples/blog/src/pages/index.astro index 6ab19b73e..b082088c8 100644 --- a/examples/blog/src/pages/index.astro +++ b/examples/blog/src/pages/index.astro @@ -4,6 +4,9 @@ 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. @@ -14,8 +17,9 @@ let description = 'The perfect starter for your perfect blog.'; let permalink = 'https://example.com/'; // Data Fetching: List all Markdown posts in the repo. -let allPosts = Astro.fetchContent('./posts/*.md'); -allPosts = allPosts.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate)); + +let allPosts = Astro.fetchContent<MarkdownFrontmatter>('./posts/*.md'); +allPosts = allPosts.sort((a, b) => new Date(b.publishDate).valueOf() - new Date(a.publishDate).valueOf()); // Full Astro Component Syntax: // https://docs.astro.build/core-concepts/astro-components/ |