/** * 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 env = require('../server/env.js'); const liveReloadServer = require('../server/liveReloadServer.js'); const {idx, getPath} = require('./utils.js'); const CWD = process.cwd(); // Component used to provide same head, header, footer, other scripts to all pages class Site extends React.Component { mobileNavHasOneRow(headerLinks) { const hasLanguageDropdown = env.translation.enabled && env.translation.enabledLanguages().length > 1; const hasOrdinaryHeaderLinks = headerLinks.some( link => !(link.languages || link.search), ); return !(hasLanguageDropdown || hasOrdinaryHeaderLinks); } render() { const tagline = idx(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 path = getPath( this.props.config.baseUrl + (this.props.url || 'index.html'), this.props.config.cleanUrl, ); const url = this.props.config.url + path; let docsVersion = this.props.version; const liveReloadScriptUrl = liveReloadServer.getReloadScriptUrl(); if (!docsVersion && fs.existsSync(`${CWD}/versions.json`)) { const latestVersion = require(`${CWD}/versions.json`)[0]; docsVersion = latestVersion; } const navPusherClasses = classNames('navPusher', { singleRowMobileNav: this.mobileNavHasOneRow( this.props.config.headerLinks, ), }); return (