#Markdown Drafts Still Built?

10 messages · Page 1 of 1 (latest)

mild swan
#

Perhaps I'm missing something obvious, but the draft frontmatter behavior doesn't seem to be working for me.

If you run npm create astro@latest and then add a draft: true to the frontmatter of any of the blog posts inside of the content folder, they are still built.

Is this intentional? It would seem from the docs that this would all you'd need to do to stop building a page...

craggy apex
#

Hi @mild swan I had the same issue. It wouldn't make sense that it is the default behavior. To be safe, I've implemented a workaround:

  const blogEntries = await getCollection("posts", ({ data }) => {
    const prod = import.meta.env.MODE === "production";
    const dev = import.meta.env.MODE === "development";
    return dev || (prod && !data.draft);
  });
#

That allows me to inspect the post as I'm writing it, without accidentally releasing it.

mild swan
#

Yep! Implemented something very similar. Seems like the documentation is wrong then, no? Isn't that the whole point of the draft frontmatter attribute, to exclude a post from being built? The documentation says nothing about the environment

#

Like this is not true 👇

#

It seems like the intention is for pages to be built regardless of environment, unless they have the draft attribute set to true

#

Unless I hear otherwise from a moderator in here I'll file a bug report on the Github repository

craggy apex
#

@mild swan I think the misunderstanding comes from "Markdown or MDX". I think it quite literally is intended to apply to .md and .mdx file extensions.

#

I used the Markdoc integration and for that, I needed the workaround above.

austere bronze