docusaurus/lib/core/DocsLayout.js

86 lines
2.8 KiB
JavaScript
Raw Normal View History

2017-07-07 13:28:29 -04:00
/**
* 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.
2017-07-07 13:28:29 -04:00
*/
2017-07-10 19:38:35 -04:00
const React = require("react");
const Container = require("./Container.js");
const Doc = require("./Doc.js");
const DocsSidebar = require("./DocsSidebar.js");
const Site = require("./Site.js");
const translation = require("../server/translation.js");
2017-07-07 13:28:29 -04:00
2017-08-15 19:55:38 -04:00
// component used to generate whole webpage for docs, including sidebar/header/footer
2017-07-07 13:28:29 -04:00
class DocsLayout extends React.Component {
render() {
const metadata = this.props.metadata;
const content = this.props.children;
const i18n = translation[this.props.metadata.language];
2017-07-07 13:28:29 -04:00
return (
<Site
config={this.props.config}
className="sideNavVisible"
title={
2017-07-10 19:38:35 -04:00
i18n
? translation[this.props.metadata.language]["localized-strings"][
this.props.metadata.localized_id
] || this.props.metadata.title
2017-07-10 19:38:35 -04:00
: this.props.metadata.title
2017-07-07 13:28:29 -04:00
}
2017-07-10 19:38:35 -04:00
description={content.trim().split("\n")[0]}
2017-07-07 13:28:29 -04:00
language={metadata.language}
2017-08-03 13:25:01 -04:00
version={metadata.version}
2017-07-07 13:28:29 -04:00
>
<div className="docMainWrapper wrapper">
<DocsSidebar metadata={metadata} />
<Container className="mainContainer">
<Doc
content={content}
config={this.props.config}
source={metadata.source}
title={
2017-07-10 19:38:35 -04:00
i18n
? translation[this.props.metadata.language][
2017-07-10 19:38:35 -04:00
"localized-strings"
][this.props.metadata.localized_id] ||
this.props.metadata.title
: this.props.metadata.title
2017-07-07 13:28:29 -04:00
}
language={metadata.language}
/>
<div className="docs-prevnext">
{metadata.previous_id &&
<a
className="docs-prev button"
2017-07-10 19:38:35 -04:00
href={metadata.previous_id + ".html#content"}
2017-07-07 13:28:29 -04:00
>
2017-07-10 19:38:35 -04:00
{" "}
{i18n
? translation[this.props.metadata.language][
2017-07-10 19:38:35 -04:00
"localized-strings"
]["previous"] || "Previous"
: "Previous"}
2017-07-07 13:28:29 -04:00
</a>}
{metadata.next_id &&
<a
className="docs-next button"
2017-07-10 19:38:35 -04:00
href={metadata.next_id + ".html#content"}
2017-07-07 13:28:29 -04:00
>
2017-07-10 19:38:35 -04:00
{i18n
? translation[this.props.metadata.language][
2017-07-10 19:38:35 -04:00
"localized-strings"
]["next"] || "Next"
: "Next"}{" "}
2017-07-07 13:28:29 -04:00
</a>}
</div>
</Container>
</div>
</Site>
);
}
}
module.exports = DocsLayout;