-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for draft pages #2392
Conversation
* implemented support for draft pages * added integration test * updated relevant documentation (english only)
🦋 Changeset detectedLatest commit: 9b2af6f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✔️ Deploy Preview for astro-docs-2 ready! 🔨 Explore the source changes: 3a19637 🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61e1c5d13dc68e0007195ee6 😎 Browse the preview: https://deploy-preview-2392--astro-docs-2.netlify.app |
Opinion: Since this is only for Markdown pages, perhaps it'd be best to include the word "markdown" in the various descriptions of this feature For instance, perhaps the CLI flag description should be "Include markdown pages marked as draft in the build". This isn't a big difference but I feel like some users might think that you can also mark non-markdown pages as draft (which would be a cool feature) even though that isn't a thing |
Agreed, "draft pages" could be interpreted as in the general context of pages. |
.changeset/ten-cougars-knock.md
Outdated
@@ -0,0 +1,5 @@ | |||
--- | |||
'astro': minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since astro < 1.0 and this is a non-breaking change this should be a patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! I will make the changes.
.changeset/ten-cougars-knock.md
Outdated
'astro': minor | ||
--- | ||
|
||
Support markdown draft pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give more a description here and give a code example? This will appear in our changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added more description, please check.
@@ -159,6 +161,34 @@ Using images or videos follows Astro's normal import rules: | |||
- Example: Image is located at `/public/assets/img/astonaut.png` → Markdown: `![Astronaut](assets/img/astronaut.png)` | |||
- Or use `import` as explained on the [imports page](/en/guides/imports#other-assets) (when using Astro's Markdown Component) | |||
|
|||
### Markdown draft pages | |||
|
|||
Markdown pages which have the property `draft` set in their frontmatter are referred to as "draft pages". By default, Astro excludes these pages from the build when building the static version of your page (i.e `astro build`), which means that you can exclude draft/incomplete pages from the production build by setting `draft` to `true`. To enable building of draft pages, you can set `buildOptions.drafts` to `true` in the configuration file, or pass the `--drafts` flag when running `astro build`. Markdown pages which do not have the `draft` property set are not affected. An example of a markdown draft page can be: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great docs
Looks great aside for a couple of things in the changeset! Seems to conform to the RFC. |
- changed type to 'patch' - added more description
// Filter pages by using conditions based on their frontmatter. | ||
Object.entries(allPages).forEach(([page, data]) => { | ||
if ('frontmatter' in data.preload[1]) { | ||
// TODO: add better type inference to data.preload[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for a followup PR that I will make.
We do not have consistent formatting for TODOs, which makes finding them a little less obvious.
For a loose check of "todo", I found 360 of these in our project. We will want to audit these at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So well done.
Looks good to me |
* feat: support draft pages * implemented support for draft pages * added integration test * updated relevant documentation (english only) * docs: explicitly mention "markdown draft pages" * chore: add changeset * chore: modify changeset - changed type to 'patch' - added more description
Changes
Testing
An integration test has been added with both possible scenarios. The test checks whether the draft markdown page in the fixture is rendered or not.
Docs
The public documentation, as well as the configuration documentation was updated. Suggestions are welcome.