diff --git a/lib/core/Head.js b/lib/core/Head.js index 030253a2e2..db37640b6f 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -18,7 +18,7 @@ class Head extends React.Component { let sourceCodeButton = this.props.config.sourceCodeButton; // defaults to github, but other values may be allowed in the future let includeGithubButton = - sourceCodeButton === 'github' || sourceCodeButton == null; + sourceCodeButton === "github" || sourceCodeButton == null; return (
@@ -36,6 +36,12 @@ class Head extends React.Component { content={this.props.config.baseUrl + this.props.config.ogImage} /> )} + {this.props.redirect && ( + )} - {includeGithubButton && + {includeGithubButton && ( - } - + )} + ); diff --git a/lib/core/Redirect.js b/lib/core/Redirect.js new file mode 100644 index 0000000000..71df971c2c --- /dev/null +++ b/lib/core/Redirect.js @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require("react"); +const fs = require("fs"); +const Head = require("./Head.js"); +const translation = require("../server/translation.js"); + +const CWD = process.cwd(); + +// Component used to provide same head, header, footer, other scripts to all pages +class Redirect extends React.Component { + render() { + const tagline = translation[this.props.language] + ? translation[this.props.language]["localized-strings"].tagline + : this.props.config.tagline; + const title = this.props.title + ? this.props.title + " · " + this.props.config.title + : (!this.props.config.disableTitleTagline && + this.props.config.title + " · " + tagline) || + this.props.config.title; + const description = this.props.description || tagline; + const url = + this.props.config.url + + this.props.config.baseUrl + + (this.props.url || "index.html"); + let latestVersion; + + const redirect = this.props.redirect || false; + + if (fs.existsSync(CWD + "/versions.json")) { + latestVersion = require(CWD + "/versions.json")[0]; + } + return ( + + + The page you are looking for has moved. If you are not redirected to + the new page in three seconds, then you can navigate to the new page + by using this link. +