Skip to content

Commit 7fe8a42

Browse files
[docs] Improve displayed versions (mui#24051)
1 parent 7646db1 commit 7fe8a42

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

docs/pages/versions.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ async function getBranches() {
3333
}
3434

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

3838
const branches = await getBranches();
39-
let versions = branches.map((n) => n.name);
39+
let versions = branches.map((branch) => branch.name);
4040
versions = versions.filter((value) => FILTERED_BRANCHES.indexOf(value) === -1);
4141
versions = versions.map((version) => ({
4242
version,
@@ -56,6 +56,17 @@ Page.getInitialProps = async () => {
5656
versions = versions.sort((a, b) =>
5757
formatVersion(b.version).localeCompare(formatVersion(a.version)),
5858
);
59+
60+
if (
61+
branches.find((branch) => branch.name === 'next') &&
62+
!versions.find((version) => /beta|alpha/.test(version.version))
63+
) {
64+
versions.unshift({
65+
version: `v${Number(versions[0].version[1]) + 1} pre-release`,
66+
url: 'https://next.material-ui.com',
67+
});
68+
}
69+
5970
versions = sortedUniqBy(versions, 'version');
6071

6172
const { demos, docs } = prepareMarkdown({ pageFilename, requireRaw });

docs/src/pages/versions/StableVersions.js renamed to docs/src/pages/versions/ReleasedVersions.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const styles = {
1919
},
2020
};
2121

22-
function StableVersions(props) {
22+
function ReleasedVersions(props) {
2323
const { classes } = props;
2424
const { versions } = React.useContext(PageContext);
2525

@@ -41,7 +41,8 @@ function StableVersions(props) {
4141
</Link>
4242
</TableCell>
4343
<TableCell>
44-
{doc.version.length >= 6 ? (
44+
{doc.version.length >= 6 &&
45+
doc.version.indexOf('pre-release') === -1 ? (
4546
<Link
4647
variant="body2"
4748
color="secondary"
@@ -60,8 +61,8 @@ function StableVersions(props) {
6061
);
6162
}
6263

63-
StableVersions.propTypes = {
64+
ReleasedVersions.propTypes = {
6465
classes: PropTypes.object.isRequired,
6566
};
6667

67-
export default withStyles(styles)(StableVersions);
68+
export default withStyles(styles)(ReleasedVersions);

docs/src/pages/versions/versions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

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

5-
## Stable versions
5+
## Released versions
66

7-
The most recent version is recommended in production.
7+
The most recent stable version (✓) is recommended for use in production.
88

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

1111
## Latest versions
1212

0 commit comments

Comments
 (0)