/** * 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 classNames = require('classnames'); const HeaderNav = require('./nav/HeaderNav.js'); const Head = require('./Head.js'); const Footer = require(process.cwd() + '/core/Footer.js'); const translation = require('../server/translation.js'); const constants = require('./constants'); const CWD = process.cwd(); // Component used to provide same head, header, footer, other scripts to all pages class Site 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 docsVersion = this.props.version || 'current'; if (fs.existsSync(CWD + '/versions.json')) { const latestVersion = require(CWD + '/versions.json')[0]; if (docsVersion === latestVersion) { docsVersion = 'current'; } } // We do not want a lang attribute for the html tag if we don't have a language set let htmlElementProps; if (this.props.language) { htmlElementProps = { lang: this.props.language, }; } else { htmlElementProps = {}; } const className = this.props.className || ''; return (
{this.props.children}
{this.props.config.algolia && (