mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 20:46:58 +02:00
Adds sitemap.xml. Adds 'Help Translate' to translatable strings. Error messages and fn name cleanups. (#136)
* added a note about needing more than one language to be enabled to allow for a drop down * Removing debug statements * Add 'Help Translate' to translatable strings, improves error messages around missing translated strings, calls write-translations on some routes * Adds sitemap.xml to live server and build. Versioning not supported. -- Also did some file name and module cache cleanups.
This commit is contained in:
parent
30eea17a24
commit
bcba05ae03
19 changed files with 495 additions and 245 deletions
|
@ -12,13 +12,15 @@ const fs = require("fs");
|
|||
const siteConfig = require(CWD + "/siteConfig.js");
|
||||
const translation = require("../../server/translation.js");
|
||||
|
||||
const translate = require("../../server/translate.js").translate;
|
||||
|
||||
const ENABLE_TRANSLATION = fs.existsSync(CWD + "/languages.js");
|
||||
const ENABLE_VERSIONING = fs.existsSync(CWD + "/versions.json");
|
||||
let versions;
|
||||
if (ENABLE_VERSIONING) {
|
||||
versions = require(CWD + "/versions.json");
|
||||
}
|
||||
require("../../server/readMetadata.js").generateDocsMetadata();
|
||||
require("../../server/readMetadata.js").generateMetadataDocs();
|
||||
const Metadata = require("../metadata.js");
|
||||
|
||||
// language dropdown nav item for when translations are enabled
|
||||
|
@ -26,6 +28,9 @@ class LanguageDropDown extends React.Component {
|
|||
render() {
|
||||
const enabledLanguages = [];
|
||||
let currentLanguage = "English";
|
||||
let helpTranslateString = translate(
|
||||
"Help Translate|recruit community translators for your project"
|
||||
);
|
||||
// add all enabled languages to dropdown
|
||||
translation["languages"].map(lang => {
|
||||
if (lang.tag == this.props.language) {
|
||||
|
@ -36,9 +41,7 @@ class LanguageDropDown extends React.Component {
|
|||
}
|
||||
enabledLanguages.push(
|
||||
<li key={lang.tag}>
|
||||
<a href={siteConfig.baseUrl + lang.tag}>
|
||||
{lang.name}
|
||||
</a>
|
||||
<a href={siteConfig.baseUrl + lang.tag}>{lang.name}</a>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
|
@ -47,11 +50,11 @@ class LanguageDropDown extends React.Component {
|
|||
return null;
|
||||
}
|
||||
// add Crowdin project recruiting link
|
||||
if (siteConfig.recruitingLink) {
|
||||
if (siteConfig.translationRecruitingLink) {
|
||||
enabledLanguages.push(
|
||||
<li key="recruiting">
|
||||
<a href={siteConfig.recruitingLink} target="_blank">
|
||||
Help Translate
|
||||
<a href={siteConfig.translationRecruitingLink} target="_blank">
|
||||
{helpTranslateString}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
|
@ -68,9 +71,7 @@ class LanguageDropDown extends React.Component {
|
|||
{currentLanguage}
|
||||
</a>
|
||||
<div id="languages-dropdown" className="hide">
|
||||
<ul id="languages-dropdown-items">
|
||||
{enabledLanguages}
|
||||
</ul>
|
||||
<ul id="languages-dropdown-items">{enabledLanguages}</ul>
|
||||
</div>
|
||||
</li>
|
||||
<script
|
||||
|
@ -188,17 +189,15 @@ class HeaderNav extends React.Component {
|
|||
className="logo"
|
||||
src={this.props.baseUrl + siteConfig.headerIcon}
|
||||
/>
|
||||
{!this.props.config.disableHeaderTitle &&
|
||||
<h2 className="headerTitle">
|
||||
{this.props.title}
|
||||
</h2>}
|
||||
{!this.props.config.disableHeaderTitle && (
|
||||
<h2 className="headerTitle">{this.props.title}</h2>
|
||||
)}
|
||||
</a>
|
||||
{ENABLE_VERSIONING &&
|
||||
{ENABLE_VERSIONING && (
|
||||
<a href={versionsLink}>
|
||||
<h3>
|
||||
{this.props.version || versions[0]}
|
||||
</h3>
|
||||
</a>}
|
||||
<h3>{this.props.version || versions[0]}</h3>
|
||||
</a>
|
||||
)}
|
||||
{this.renderResponsiveNav()}
|
||||
</header>
|
||||
</div>
|
||||
|
@ -223,21 +222,21 @@ class HeaderNav extends React.Component {
|
|||
if (link.doc && !fs.existsSync(CWD + "/../docs/")) {
|
||||
throw new Error(
|
||||
"You have 'doc' in your headerLinks, but no 'docs' folder exists one level up from " +
|
||||
"'website' folder. Are you running the examples? If so, make sure you rename " +
|
||||
"'docs-examples-from-docusaurus' to 'docs'."
|
||||
"'website' folder. Are you running the examples? If so, make sure you rename " +
|
||||
"'docs-examples-from-docusaurus' to 'docs'."
|
||||
);
|
||||
}
|
||||
if (link.blog && !fs.existsSync(CWD + "/blog/")) {
|
||||
throw new Error(
|
||||
"You have 'blog' in your headerLinks, but no 'blog' folder exists in your " +
|
||||
"website folder. Are you running the examples? If so, make sure you rename " +
|
||||
"'blog-examples-from-docusaurus' to 'blog'."
|
||||
"website folder. Are you running the examples? If so, make sure you rename " +
|
||||
"'blog-examples-from-docusaurus' to 'blog'."
|
||||
);
|
||||
}
|
||||
if (link.page && !fs.existsSync(CWD + "/pages/")) {
|
||||
throw new Error(
|
||||
"You have 'page' in your headerLinks, but no 'pages' folder exists in your " +
|
||||
"'website' folder."
|
||||
"'website' folder."
|
||||
);
|
||||
}
|
||||
// We will add search bar to end if location not specified
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue