#Unexpected error while parsing content entry IDs and slugs.

4 messages · Page 1 of 1 (latest)

spare rune
#

I am using keystatic to author my posts and I have it placing the posts in content/articles/

My config file looks like this:

const articlesCollection = defineCollection({
  schema: z.object({
    title: z.string(),
    excerpt: z.string(),
    publishedAt: z.date(),
    category: z.enum(["catholicism", "life", "short-stories"]),
  }),
});

const filmCollection = defineCollection({
  type: "data",
  schema: z.object({
    title: z.string(),
    embedUrl: z.string().url(),
    videoUrl: z.string().url(),
    summary: z.string(),
  }),
});

export const collections = {
  articles: articlesCollection,
  films: filmCollection,
};

When I try to get articles via getCollection, I get that error in the frontend. Also, accessing films gives a no overload matches this call. I am trying to display the collection in a file with the path/pages/stories/short-stories.astro

pine yokeBOT
#

Hi @spare rune. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, it seems like you might be encountering a couple of different issues.

  1. Unexpected error while parsing content entry IDs and slugs: This error might be due to the way you're defining your collection or trying to access it. In the knowledge sources, it's shown that the defineCollection function is used to define the schema of the collection, and the getCollection function is used to fetch the collection. Make sure you're using these functions correctly. Also, ensure that the slugs for your articles are unique and correctly formatted.

  2. No overload matches this call when accessing films: This error typically occurs when the arguments you're passing to a function don't match any of the function's expected argument types. In the case of getCollection, it expects a string argument representing the name of the collection. Make sure you're passing the correct argument to this function.

Here's an example of how to fetch a collection based on the knowledge sources:

---
import { getCollection } from "astro:content";
const allPosts = (await getCollection("posts")) as any[];
---

If you're still encountering issues, it might be helpful to review the Astro documentation (https://docs.astro.build/core-concepts/collections) on collections for more information.