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

[docs] Improve displayed versions #24051

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/pages/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ async function getBranches() {
}

Page.getInitialProps = async () => {
const FILTERED_BRANCHES = ['latest', 'staging', 'l10n', 'next'];
const FILTERED_BRANCHES = ['latest', 'l10n', 'next'];

const branches = await getBranches();
let versions = branches.map((n) => n.name);
let versions = branches.map((branch) => branch.name);
versions = versions.filter((value) => FILTERED_BRANCHES.indexOf(value) === -1);
versions = versions.map((version) => ({
version,
Expand All @@ -55,6 +55,17 @@ Page.getInitialProps = async () => {
versions = versions.sort((a, b) =>
formatVersion(b.version).localeCompare(formatVersion(a.version)),
);

if (
branches.find((branch) => branch.name === 'next') &&
!versions.find((version) => /beta|alpha/.test(version.version))
) {
versions.unshift({
version: `v${Number(versions[0].version[1]) + 1} pre-release`,
url: 'https://next.material-ui.com',
});
}

versions = sortedUniqBy(versions, 'version');

const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const styles = {
},
};

function StableVersions(props) {
function ReleasedVersions(props) {
const { classes } = props;
const { versions } = React.useContext(PageContext);

Expand All @@ -47,7 +47,8 @@ function StableVersions(props) {
</Link>
</TableCell>
<TableCell>
{doc.version.length >= 6 ? (
{doc.version.length >= 6 &&
doc.version.indexOf('pre-release') === -1 ? (
<Link
variant="body2"
color="secondary"
Expand All @@ -66,8 +67,8 @@ function StableVersions(props) {
);
}

StableVersions.propTypes = {
ReleasedVersions.propTypes = {
classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(StableVersions);
export default withStyles(styles)(ReleasedVersions);
6 changes: 3 additions & 3 deletions docs/src/pages/versions/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<p class="description">You can come back to this page and switch the version of the docs you're reading at any time.</p>

## Stable versions
## Released versions

The most recent version is recommended in production.
The most recent stable version is recommended in production.
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved

{{"demo": "pages/versions/StableVersions.js", "hideToolbar": true, "bg": "inline"}}
{{"demo": "pages/versions/ReleasedVersions.js", "hideToolbar": true, "bg": "inline"}}

## Latest versions

Expand Down