#Different docsSchemas for Starlight Docs Content Loader

3 messages · Page 1 of 1 (latest)

tardy hill
#

Is there a way to pass some sort of union to the docsSchema?

I have two different schemas for template: "doc" and template: "splash"

When I do it like this, the schema validation works, but the Astro.props.entry.data in my MarkdownContent.astro overwrite has neither the layout nor lexical key

atomic sentinel
tardy hill
#

Ahh yeah... Thanks for the link, you're a legend! Now that I see how you defined the union it was so obvious 😄
The Objects in the union needed to have the template literals in them

z.object({
            template: z.literal("doc"),
            lexical: lexicalRoot,
          }),
          z.object({
            template: z.literal("splash"),
            layout: z.array(layoutBlock),
          }),

Added code to make it more searchable