Skip to content

feat(v2): docs version banner configuration option - #5052

Merged
slorber merged 5 commits into
masterfrom
slorber/version-banner-config
Jun 24, 2021
Merged

slorber merged 5 commits into
masterfrom
slorber/version-banner-config

Conversation

@slorber

@slorber slorber commented Jun 24, 2021 •

Copy link
Copy Markdown
Collaborator

Breaking changes:

  • @theme/DocVersionSuggestions component API modified, and component is renamed to DocVersionBanner.
  • Both @theme/DocVersionSuggestions and @theme/DocItem should probably be reswizzled/updated

Motivation

Fixes #3013

By default, we display a banner at the top of docs versions that are not the latest version, saying the version is either unreleased or unmaintained.

This is a problem for some sites that want to disable this banner.

Currently, the only solution is swizzle the banner component, which is a bit annoying for users.

This PR adds a new version config option so that the banner can be customized/disabled per-version.

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

This may not be the best API in case you want to disable the site on ALL banners at once, but is a good low-level first step enabling the user to disable banners without swizzling. We can introduce more APIs for that later.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

tests

@slorber slorber added pr: new feature This PR adds a new API or behavior. pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. labels Jun 24, 2021
@slorber
slorber requested a review from lex111 as a code owner June 24, 2021 15:24
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 24, 2021
@netlify

netlify Bot commented Jun 24, 2021 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jun 24, 2021 •

Copy link
Copy Markdown

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 91
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5052--docusaurus-2.netlify.app/

@github-actions

github-actions Bot commented Jun 24, 2021 •

Copy link
Copy Markdown

Size Change: -40 B (0%)

Total Size: 571 kB

Filename Size Change
website/build/assets/js/main.********.js 386 kB -40 B (0%)
ℹ️ View Unchanged
Filename Size
website/build/assets/css/styles.********.css 87.7 kB
website/build/blog/2017/12/14/introducing-docusaurus/index.html 66.4 kB
website/build/docs/introduction/index.html 235 B
website/build/index.html 31.1 kB

compressed-size-action

@slorber
slorber merged commit 364051f into master Jun 24, 2021
@slorber
slorber deleted the slorber/version-banner-config branch August 17, 2021 17:49
mostlyobvious added a commit to RailsEventStore/rails_event_store that referenced this pull request Jul 11, 2025
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
* refactor DocVersionBanner => versionMetadata prop should be forwarded instead of using "useActiveVersion" + global data

* docs version banner configuration

* add doc for versions.banner

* fix tests

* improve docs plugin option api doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow disabling or customizing the next version banner

2 participants