-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(netlify): more resilient netlify docs alert implementation
Uses the already built-in netlify configuration variables that will be injected by the netlify build environment, which should allow use to not have to configure anything extra to get this feature to work properly. Also adds some more information about the deployment, specifying whether or not it's a pull request (and redirects to the right pr link), or if it's being deployed from a specific branch.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import Alert from 'react-bootstrap/Alert'; | ||
import Container from 'react-bootstrap/Container'; | ||
import Row from 'react-bootstrap/Row'; | ||
|
||
function MasterDocsAlert() { | ||
let deploymentDetails = null; | ||
if (process.env.NETLIFY) { | ||
if (process.env.PULL_REQUEST === 'true') { | ||
deploymentDetails = ( | ||
<span> | ||
a{' '} | ||
<Alert.Link | ||
href={`https://github.com/react-bootstrap/react-bootstrap/pull/${process.env.REVIEW_ID}`} | ||
> | ||
pull request | ||
</Alert.Link> | ||
</span> | ||
); | ||
} else { | ||
deploymentDetails = `the ${process.env.BRANCH} branch`; | ||
} | ||
} | ||
return process.env.NETLIFY ? ( | ||
<Container fluid> | ||
<Row> | ||
<Alert variant="warning" className="w-100"> | ||
You are currently viewing the auto-generated docs from{' '} | ||
{deploymentDetails}. The docs for the current release are available at{' '} | ||
<Alert.Link href="https://react-bootstrap.github.io/"> | ||
https://react-bootstrap.github.io/ | ||
</Alert.Link> | ||
</Alert> | ||
</Row> | ||
</Container> | ||
) : null; | ||
} | ||
|
||
export default MasterDocsAlert; |
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