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.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
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");
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 = this.props.config[this.props.metadata.language];
return (
<Site
config={this.props.config}
className="sideNavVisible"
section="docs"
title={
2017-07-10 19:38:35 -04:00
i18n
? this.props.config[this.props.metadata.language][
"localized-strings"
][this.props.metadata.localized_id] || this.props.metadata.title
: 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}
>
<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
? this.props.config[this.props.metadata.language][
"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
? this.props.config[this.props.metadata.language][
"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
? this.props.config[this.props.metadata.language][
"localized-strings"
]["next"] || "Next"
: "Next"}{" "}
2017-07-07 13:28:29 -04:00
</a>}
</div>
</Container>
</div>
</Site>
);
}
}
module.exports = DocsLayout;