Skip to content

Drafts filtering behavior, configuration, flags, and docs needs cleanup. #7324

@bradobro

Description

@bradobro

What version of astro are you using?

2.6.1

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Firefox

Describe the Bug

This may simply be a problem with my understanding of the behavior or a clarification in the docs.

Background

I've looked at #440 and the docs regarding the build --drafts flag and the markdown.drafts configuration.

It looks to me like:

Astro's collection API is a nice addition, and it prevents 1000 ad-hoc almost compatible similar implementations from sprouting up. The idea of having items in a collection that aren't ready for production (drafts) seems like a good thing to have a convention around.

Proposal

This will take some discussion, but to start the discussion, I propose that:

  • When an item is marked draft it is included in the by default in astro dev and excluded by default in astro build, which can be overridden by config.markdown.drafts, which can be overridden by the --drafts flag.

  • When drafts are excluded, they're excluded everywhere. They don't exist--not their empty folders, their html, nor their RSS feeds. This prevents accidental info leaks and other embarrassments.

  • This behavior should be implemented in the collections API.

Next Steps

All those assertions are debatable, but I think form a good starting point. If we can agree on behavior and api, I'd be willing to submit a PR.

35055

Link to Minimal Reproducible Example

https://stackblitz.com/github/bradobro/astro-test-drafts?file=README.md

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions