/** * 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 Container = require('./Container.js'); const Doc = require('./Doc.js'); const DocsSidebar = require('./DocsSidebar.js'); const OnPageNav = require('./nav/OnPageNav.js'); const Site = require('./Site.js'); const translation = require('../server/translation.js'); const classNames = require('classnames'); const path = require('path'); const url = require('url'); // component used to generate whole webpage for docs, including sidebar/header/footer class DocsLayout extends React.Component { getRelativeURL = (from, to) => { const extension = this.props.config.cleanUrl ? '' : '.html'; const relativeHref = path .relative(from, to) .replace('\\', '/') .replace(/^\.\.\//, '') + extension; return url.resolve( `${this.props.config.baseUrl}${this.props.metadata.permalink}`, relativeHref ); }; render() { const metadata = this.props.metadata; const content = this.props.children; const i18n = translation[this.props.metadata.language]; let DocComponent = Doc; if (this.props.Doc) { DocComponent = this.props.Doc; } const title = i18n ? translation[this.props.metadata.language]['localized-strings'][ this.props.metadata.localized_id ] || this.props.metadata.title : this.props.metadata.title; const hasOnPageNav = this.props.config.onPageNav === 'separate'; return (
{hasOnPageNav && ( )}
); } } module.exports = DocsLayout;