diff options
author | 2021-09-14 09:14:39 -0400 | |
---|---|---|
committer | 2021-09-14 09:14:39 -0400 | |
commit | b6a75494b1c128503de3eba5363b46528142d8b2 (patch) | |
tree | 90098b84b352c7e60d8db4b2e18f109b6b7c6482 /examples/blog/src/pages | |
parent | 72c916535d29fb92ab10efcf62308041ba2858a7 (diff) | |
download | astro-b6a75494b1c128503de3eba5363b46528142d8b2.tar.gz astro-b6a75494b1c128503de3eba5363b46528142d8b2.tar.zst astro-b6a75494b1c128503de3eba5363b46528142d8b2.zip |
Add types to examples and docs (#1347)
* Adds a changeset
* Add types to examples and docs
* Make changes based on review feedback
* Avoid using the variable named props
* Make path a const
Diffstat (limited to 'examples/blog/src/pages')
-rw-r--r-- | examples/blog/src/pages/index.astro | 8 |
1 files changed, 6 insertions, 2 deletions
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/ |