-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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] Keep the current version into account #11595
[docs] Keep the current version into account #11595
Conversation
518ad09
to
6fdb597
Compare
|
||
this.setState({ versions }); | ||
let docs = branches.map(n => n.name); | ||
docs.sort().reverse(); |
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.
The GitHub API returns the branches already sorted (regardless of the order they were added), so while harmless, sort()
won't actually do anything here as I understand it.
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.
The GitHub API returns the branches already sorted
Is this by design or just by luck?
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.
It appears to be by design - I tested it every which way, but keeping sort()
can't do any harm.
this.setState({ versions }); | ||
let docs = branches.map(n => n.name); | ||
docs.sort().reverse(); | ||
docs.pop(); // most recent first & remove 'latest' |
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.
Comment doesn't match the code.
}); | ||
docs = uniqBy(docs, 'version'); | ||
docs[0].url = 'https://material-ui.com'; | ||
this.setState({ docs }); | ||
}; |
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.
Why not just add the current version to the versions array if it isn't already present (i.e if there isn't a version specific branch on GitHub)? Job done.
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.
It's what the uniq
is doing without the need for a condition.
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 meant instead of the entire block of code, as well as not needing the dependancy. The rest is (was) already taken care of, although I appreciate the desire to move the logic out of the render code.
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.
let versions = [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]
> [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]
versions.unshift('v1.2.0')
> [ 'v1.2.0', 'v1.2.0', 'v1.1.0', 'v1.0.0' ]
versions = [...new Set(versions)]
> [ 'v1.2.0', 'v1.1.0', 'v1.0.0' ]
docs.push({ | ||
version: `v${process.env.LIB_VERSION}`, | ||
url: document.location.origin, | ||
}); |
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.
docs.unshift()
?
6fdb597
to
9d4f00c
Compare
So we don't have to push a branch for every version of the documentation we push.