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

Proposal: add unlisted/draft banners in dev mode #8285

Closed
1 of 2 tasks
slorber opened this issue Nov 3, 2022 · 4 comments · Fixed by #10376
Closed
1 of 2 tasks

Proposal: add unlisted/draft banners in dev mode #8285

slorber opened this issue Nov 3, 2022 · 4 comments · Fixed by #10376
Labels
apprentice Issues that are good candidates to be handled by a Docusaurus apprentice / trainee proposal This issue is a proposal, usually non-trivial change

Comments

@slorber
Copy link
Collaborator

slorber commented Nov 3, 2022

Have you read the Contributing Guidelines on issues?

Motivation

#8004 brings support for unlisted to all 3 content plugins, including a banner to make it clear a content is unlisted:

image

I think it could improve the DX to also display such a banner in dev for both draft: true and unlisted: true

Note in our current implementation, the doc metadata.unlisted is never true in dev mode so this metadata is not a good way to display the banner in dev. We could read frontMatter.unlisted directly instead.

Self-service

  • I'd be willing to do some initial work on this proposal myself.
@slorber slorber added the proposal This issue is a proposal, usually non-trivial change label Nov 3, 2022
@slorber slorber added the apprentice Issues that are good candidates to be handled by a Docusaurus apprentice / trainee label Sep 25, 2023
@Airkro
Copy link

Airkro commented Nov 23, 2023

Thanks Docusaurus 3.0, now is easy to doing this by create a remark plugins:

https://github.com/show-docs/remark-docusaurus/blob/722fbfd7eefe48ebce280ae137a71f9973d00578/lib/draft-admonition.mjs

@dkoprowski
Copy link

dkoprowski commented Jul 24, 2024

I can see the "Unlisted page" banner in production mode.

I thought that it would only be visible in the dev mode; when I add unlisted: true to the Front Matter of either page or blog post, I can see the banner in production mode.

Steps to reproduce:

  1. add unlisted: true to the Front Matter of either page or blog post
  2. npm run build
  • I received the following info: [INFO] [en] Creating an optimized production build...
  1. npm run serve (or put "build" folder content on any server)
  2. the "Unlisted" banner is visible on a page with unlisted: true flag in prod and dev modes

Expected result: The "Unlisted" banner is not visible in production mode.

Should I create a separate issue for that?

Screenshot 2024-07-24 at 10 57 49

Additional info:

    "@docusaurus/core": "^3.4.0",
    "@docusaurus/plugin-ideal-image": "^3.4.0",
    "@docusaurus/preset-classic": "^3.4.0",

@OzakIOne
Copy link
Collaborator

OzakIOne commented Jul 24, 2024

@dkoprowski
The behavior seems to be expected according to the documentation for unlisted documents

If you expect a different behaviour indeed you should create a separate issue though i'm not sure if we'll modify this behavior directly unless there is a demand for that.

Also it might be possible to achieve what you request by creating a remark plugin to remove the banner of unlisted content only during production build (i'm not sure about that)

@slorber
Copy link
Collaborator Author

slorber commented Jul 25, 2024

Yes it's expected to see the banner in production mode, this way you know that the page is unlisted and don't forget to remove the flag once ready. I'd like to keep it this way.

But this can easily be changed by swizzling @theme/DocItem/Layout and not rendering the banner in the doc layout. This means that until we fix this issue (showing banners in devs), you will get no banner at all in both dev/prod modes.

The banner is not in the Markdown so it can't be removed with a remark plugin. At best you can remove the unlisted front matter, but then your doc becomes listed (which removes the banner, but may not be what you want)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apprentice Issues that are good candidates to be handled by a Docusaurus apprentice / trainee proposal This issue is a proposal, usually non-trivial change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants