-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(v2): add a banner that links to latest version of documentation #2916
Merged
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
19301c9
feat(v2): add metadata to indicate the document is old
fb3e311
feat(v2): add badge that links old versions to latest version
teikjun 4358f79
feat(v2): fix test related to metadata
8aef76d
feat(v2): fix formatting
1629d92
feat(v2): fix formatting
teikjun 3239dff
feat(v2): use Link component instead of anchor tag
teikjun 7916468
feat(v2): add pramlink to latest docs
2e89fde
feat(v2): add more vibrant warning message
c4b1159
feat(v2): position the banner above the article
teikjun 85ea598
feat(v2): link latest version to intro page
teikjun 2d70251
fix(v2): fix some test cases
teikjun 20b222f
feat(v2): fix tests
f4a2fcd
feat(v2): change banner to warning orange
teikjun 32b7b07
feat(v2): compute root route from sidebar
711dba8
style(v2): fix formatting
teikjun d0f1ff3
feat(v2): use homeid if provided to compute base route
17c7e3a
feat(v2): rename functions and fix a corner case
4dfc06e
feat(v2): fix formating
10e7dd7
feat(v2): compute homepageurl
373baf5
style(v2): improve code quality
teikjun 12ef010
style(v2): unbold fullstop for consistency
teikjun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | |
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
import DocPaginator from '@theme/DocPaginator'; | ||
import useTOCHighlight from '@theme/hooks/useTOCHighlight'; | ||
import Link from '@docusaurus/Link'; | ||
|
||
import clsx from 'clsx'; | ||
import styles from './styles.module.css'; | ||
|
@@ -68,6 +69,7 @@ function DocItem(props) { | |
lastUpdatedAt, | ||
lastUpdatedBy, | ||
version, | ||
isOld, | ||
} = metadata; | ||
const { | ||
frontMatter: { | ||
|
@@ -115,6 +117,11 @@ function DocItem(props) { | |
<span className="badge badge--secondary"> | ||
Version: {version} | ||
</span> | ||
{isOld ? ( | ||
<span className="badge badge--secondary margin-horiz--xs"> | ||
<Link to="/docs"> Go to latest version </Link> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The /docs url is configurable, so it's not a good idea to hardcode the link to /docs here, + there's no guarantee that the user used the docs "homePageId" feature. See https://v2.docusaurus.io/docs/docs-introduction/#docs-only-mode |
||
</span> | ||
) : null} | ||
</div> | ||
)} | ||
{!hideTitle && ( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we should rather try to compute, for each doc, what's the permalink to the latest version of the same doc.
maybe we need a property like
latestPermalink
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.
some docs may get deleted in newer version of doc
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.
In such case latestPermalink would be undefined, and you wouldn't add the link?
Ah that's right, you want to link to the docs root, not necessarily the same doc in another version, so this is probably overkill.