Skip to content
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

Merged
merged 4 commits into from
Jan 19, 2022
Merged

Implement support for draft pages #2392

merged 4 commits into from
Jan 19, 2022

Conversation

retronav
Copy link
Contributor

Changes

  • implemented support for draft pages
  • added integration test
  • updated relevant documentation (english only)

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.

* implemented support for draft pages
* added integration test
* updated relevant documentation (english only)
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2022

🦋 Changeset detected

Latest commit: 9b2af6f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs labels Jan 14, 2022
@netlify
Copy link

netlify bot commented Jan 14, 2022

✔️ 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

@Princesseuh
Copy link
Member

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

@retronav
Copy link
Contributor Author

Agreed, "draft pages" could be interpreted as in the general context of pages.

@@ -0,0 +1,5 @@
---
'astro': minor
Copy link
Contributor

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.

Copy link
Contributor Author

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.

'astro': minor
---

Support markdown draft pages
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great docs

@matthewp
Copy link
Contributor

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]
Copy link
Contributor

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.

Copy link
Contributor

@jonathantneal jonathantneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So well done.

@matthewp
Copy link
Contributor

Looks good to me

@jonathantneal jonathantneal merged commit 24aa324 into withastro:main Jan 19, 2022
@github-actions github-actions bot mentioned this pull request Jan 19, 2022
@retronav retronav deleted the feat/draft-pages branch January 30, 2022 15:06
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants