Skip to content

Commit

Permalink
[docs] Improve displayed versions
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 19, 2020
1 parent 259253d commit 4d71b7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
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,7 @@ 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 +66,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.

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

## Latest versions

Expand Down

0 comments on commit 4d71b7b

Please sign in to comment.