Skip to content

Commit

Permalink
Merge branch 'lesson-20' into lesson-21
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolovlazar committed Nov 11, 2023
2 parents 3426f03 + b677fee commit ebb3914
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pages/blog/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
return paginate(posts, { pageSize: 3 });
};
const page: Page<CollectionEntry<'blog'>> = Astro.props.page;
// In Lesson 10 I'm setting the page's type by directly assigning it
// (const page: Page<CollectionEntry<'blog'>> = ...)
// That won't work in recent versions of Astro because if we don't define
// `type Props`, Astro.props will be a record of type `Record<string, unknown>`
// and we can't cast an `unknown` to the `Page` type.
// To fix this, we need to define `type Props` and set the page type in it,
// instead of casting the `page` constant to it.
type Props = {
page: Page<CollectionEntry<'blog'>>;
};
const page = Astro.props.page;
---

<Layout seo={{ title: 'Blog posts' }}>
Expand Down

0 comments on commit ebb3914

Please sign in to comment.