);
});
// if no languages are enabled besides English, return null
if (enabledLanguages.length < 1) {
return null;
}
// add Crowdin project recruiting link
if (siteConfig.translationRecruitingLink) {
enabledLanguages.push(
);
}
}
// header navbar used by all pages generated with docusaurus
class HeaderNav extends React.Component {
constructor() {
super();
this.state = {
slideoutActive: false,
};
}
// function to generate each header link, used with each object in siteConfig.headerLinks
makeLinks(link) {
let href;
if (link.search && this.props.config.algolia) {
// return algolia search bar
return (
);
} else if (link.languages) {
return (
// return language dropdown
);
} else if (link.doc) {
// set link to document with current page's language/version
let id;
if (!ENABLE_VERSIONING || this.props.version === 'next') {
id = this.props.language + '-' + link.doc;
} else {
id =
this.props.language +
'-version-' +
(this.props.version || versions[0]) +
'-' +
link.doc;
}
if (!Metadata[id]) {
if (id != link.doc) {
throw new Error(
"It looks like you've enabled language support, but haven't provided translated files. The document with id: '" +
id +
"' doesn't exist."
);
}
throw new Error(
'A headerLink is specified with a document that does not exist. No document exists with id: ' +
link.doc
);
}
href = this.props.config.baseUrl + Metadata[id].permalink;
} else if (link.page) {
// set link to page with current page's language if appropriate
if (fs.existsSync(CWD + '/pages/en/' + link.page + '.js')) {
href =
siteConfig.baseUrl + this.props.language + '/' + link.page + '.html';
} else {
href = siteConfig.baseUrl + link.page + '.html';
}
} else if (link.href) {
// set link to specified href
href = link.href;
} else if (link.blog) {
// set link to blog url
href = this.props.baseUrl + 'blog';
}
return (
);
}
renderResponsiveNav() {
const headerLinks = this.props.config.headerLinks;
// add language drop down to end if location not specified
let languages = false;
headerLinks.forEach(link => {
if (link.languages) {
languages = true;
}
});
if (!languages) {
headerLinks.push({languages: true});
}
let search = false;
headerLinks.forEach(link => {
if (
link.doc &&
!fs.existsSync(CWD + '/../' + readMetadata.getDocsPath() + '/')
) {
throw new Error(
"You have 'doc' in your headerLinks, but no '" +
readMetadata.getDocsPath() +
"' folder exists one level up from " +
"'website' folder. Did you run `docusaurus-init` or `npm run 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. Did you run `docusaurus-init` or `npm run 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."
);
}
// We will add search bar to end if location not specified
if (link.search) {
search = true;
}
});
if (!search && this.props.config.algolia) {
headerLinks.push({search: true});
}
return (