#Get CollectionEntry<> type into Astro.props

4 messages · Page 1 of 1 (latest)

fallow mulch
#

Hello folks,

I am using getStaticPaths() to get all the entries from a collection in a [slug].astro file.

export async function getStaticPaths() {
  const newsletterIssues = await getCollection("newsletter");

  return newsletterIssues.map((entry) => ({
    params: { slug: entry.slug },
    props: { entry },
  }));
}

When getting entry into props, it has the correct type CollectionEntry<"newsletter">, but it doesn't seem to be picked up later by Astro.props.

// Render the markdown content
const { entry } = Astro.props;
const { Content } = await entry.render();

While I understand why this happens, are there any good practices of how to correctly pass down the type to Astro.props? It's unfortunate because I cannot properly get the types/fields later in the code..

lapis rover
fallow mulch
#

Oh no I didn’t get to that part of the documentation, sorry 😭