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

Allow disabling or customizing the next version banner #3013

Closed
omry opened this issue Jun 29, 2020 · 19 comments · Fixed by #5052
Closed

Allow disabling or customizing the next version banner #3013

omry opened this issue Jun 29, 2020 · 19 comments · Fixed by #5052
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@omry
Copy link

omry commented Jun 29, 2020

🚀 Feature

v58 adds this banner:
image

I would like to either disable it or customize it to something like:

This is the documentation for the next version of Hydra.
It is not yet released, please report any issues.

The documentation for the stable version is [here](/foo/bar).
@omry omry added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. status: needs triage This issue has not been triaged by maintainers labels Jun 29, 2020
@slorber
Copy link
Collaborator

slorber commented Jun 30, 2020

Hi again :)

There are multiple things that we plan to do for versioning (see feedbacks here: #2302).

One of them is to be able to use the next version as the "current version", ie for example the /docs/myDoc would lead to the root /docs/myDoc.md instead of versioned_docs/latestversion/myDoc.md. This way, you wouldn't get such banner on the next version. Can this solve your problem?


We could support customizing these banners, from the messages to the admonition type/color.

For this message:

image

This wouldn't be so straightforward because we need to "inject" the link in the user message template here, it has been requested that this link is "dynamic", ie this link on /docs/next/myDoc would link to /docs/myDoc, not just the root doc

Is there a way we could improve this 2nd message in a generic way so that it fits your usecase, and would be a decent message for all usecases?

One solution we could also use is to make a dedicated component for showing this banner, allowing you to swizzle it and customize easily.

@omry
Copy link
Author

omry commented Jun 30, 2020

Hi @slorber!

One of them is to be able to use the next version as the "current version", ie for example the /docs/myDoc would lead to the root /docs/myDoc.md instead of versioned_docs/latestversion/myDoc.md. This way, you wouldn't get such banner on the next version. Can this solve your problem?

In this specific case, no:
I am in a pre-release stage and I am not ready to change the default documentation to the new version.
I want people using the pre-release to have easy access to the documentation, but until the rc matures enough I am not pushing it aggressively.

This wouldn't be so straightforward because we need to "inject" the link in the user message template here, it has been requested that this link is "dynamic", ie this link on /docs/next/myDoc would link to /docs/myDoc, not just the root doc

Yeah, I figured it could be involved.
I am assuming that by dynamic you mean build-time dynamic. not really dynamic.
you could introduce use useBaseUrl() support into a micro templating language, but yeah - it's a bit much.

I am not familiar with the Swizzle approach (I saw it mentioned but never used it with D2 yet). a dedicated component sounds like a promising direction.

Is there a way we could improve this 2nd message in a generic way so that it fits your usecase, and would be a decent message for all usecases?

It really depends on what we want to tell the user. The current banner is telling the user:
"You should not be here, go there."

What I want to tell the user is more like:
"There is some danger here, but feel free to stick around".

Not sure there is a single message that conveys both messages at the same time.

@slorber
Copy link
Collaborator

slorber commented Jul 1, 2020

This PR has some versioning related refactorings also relative to the banner: #2971

I'll extract this part as a dedicated component so that it can be more easily swizzled in isolation

@slorber
Copy link
Collaborator

slorber commented Jul 24, 2020

Hey all, this is feature is now released!
If you like it, don't forget to retweet 😄
https://twitter.com/docusaurus/status/1286715187983048704

(there's a new dedicated theme comp)

@omry
Copy link
Author

omry commented Jul 25, 2020

@slorber
Copy link
Collaborator

slorber commented Jul 25, 2020 via email

@omry
Copy link
Author

omry commented Jul 25, 2020

Hydra and Slash are quiet unique. I don't think you will find any other projects with similar logos.

@slorber
Copy link
Collaborator

slorber commented Aug 14, 2020

Check this versioning related RFC: #3285

@LoicPoullain
Copy link
Contributor

Would it be also possible to allow disabling or customizing the banner of past versions?

Capture d’écran 2020-12-16 à 16 01 16

The current message hints that past versions are not maintained anymore which can be wrong. In the case of FoalTS, past versions have a lifetime during which bugs and security holes are fixed even if no new features are added.

I currently use this (hacky) workaround:

.alert.alert--warning.margin-bottom--md {
  display: none;
}

@slorber
Copy link
Collaborator

slorber commented Dec 16, 2020

for now the best is to swizzle the component and implement the UI you prefer

In any case I'm not sure we'll be able to find a theme API surface that will satisfy all our users use-cases, so the solution we may find is likely a best effort to solve most common usecases

@LoicPoullain
Copy link
Contributor

Thank you for the tip. I was able to override the content with the following command (v2.0.0-alpha.69):

npm run swizzle @docusaurus/theme-classic DocVersionSuggestions --  --danger

@Yorkemartin
Copy link

I've been trying to figure out how to remove the "next" version entirely - seems like maybe it was implemented but I cant find and docs mentioning it. Any tips on how to achieve this? @slorber

@slorber
Copy link
Collaborator

slorber commented Jun 24, 2021

This will be fixed in #5052 and beta.2

For now, we just introduce an API that permits to customize this banner on a per-version basis:

const docsOptions = {
  versions: {
    current: {
      banner: "none"
    }
    "1.0.0": {
      banner: "none"
    }
  }
};

This may not be the simplest API in case you want to disable ALL the versions at once but should be good enough to not requiring swizzling anymore.

We may add new APIs in the future, also may provide a way to define a custom banner/message. Let me know if the current API is still preventing you from doing what you want.

Note: even if you can't provide labels directly through config, the hardcoded predefined labels for "unreleased" and "unmaintained" are configurable thanks to the i18n support (example translation key theme.docs.versions.unmaintainedVersionLabel)

Note: there's a breaking change, as the existing DocVersionSuggestions component has been renamed/refactored. Make sure to upgrade your code after upgrading.

@slorber
Copy link
Collaborator

slorber commented Jun 24, 2021

@Yorkemartin

I've been trying to figure out how to remove the "next" version entirely - seems like maybe it was implemented but I cant find and docs mentioning it. Any tips on how to achieve this? @slorber

There is an includeCurrentVersion: false option so that the website/docs folder is not included in your site (only the versioned folder will be displayed)

(previously called: excludeNextVersionDocs: true but has been renamed)

younho9 added a commit to younho9/TIL that referenced this issue Jun 26, 2021
@GPMueller
Copy link

This may not be the simplest API in case you want to disable ALL the versions at once but should be good enough to not requiring swizzling anymore.

@slorber is there by any chance a follow-up issue or some plan to implement setting the default for all versions or deactivating the banner overall? I couldn't find one and it doesn't seem to be part of #3285.
Seems to me that it would help with configuration of CI-maintained docs.

@slorber
Copy link
Collaborator

slorber commented Feb 9, 2022

@GPMueller yes we have configuration options to customize the banner for each versions independently

(not a global docs config, but it's probably good enough).

https://docusaurus.io/docs/versioning#configuring-versioning-behavior

image

Also for more advanced use-cases we have extracted all this feature in DocVersionBanner that you can swizzle and render null if you want.

@filipermit
Copy link

I'm trying to change the text of the banner, I attempted Swizzling it, but I don't get many customisation options. Any help?

@slorber
Copy link
Collaborator

slorber commented Sep 29, 2022

It's my plan to allow more flexibility options in Docusaurus on various axis: navbar items, footer items, sidebar (docs+blog) items... and also docs version banner items. See also temp workaround for custom navbar items here: #7227

For now we only provide a limited set of hardcoded banner item types, but we'd like to provide custom version banner items that you can register and implement yourself.

It's not clear to me how to help you considering you don't say what you want to achieve, but in any case, swizzling DocVersionBanner is the only solution atm and gives you 100 flexibility, at the cost of having to maintain the code. I have no idea what you mean by "customization options" that you couldn't achieve by modifying our code.

@Sadhvik-Modak
Copy link

adding this includeCurrentVersion: false solved...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants