mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-27 15:07:53 +02:00
feat(v2): headerlinks (#1074)
* feat(v2): headerlinks * fix test * nits * remove tictactoe: * headerIcon * nits * remove lang dropdown * fix failing test * search box * algolia search * use babel-eslint to resolve dynamic import * nits * favicon and title * Update .eslintignore
This commit is contained in:
parent
d4458b394c
commit
85336649d3
66 changed files with 1205 additions and 2292 deletions
|
@ -25,6 +25,9 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
'projectName',
|
||||
'baseUrl',
|
||||
'url',
|
||||
'headerLinks',
|
||||
'headerIcon',
|
||||
'favicon',
|
||||
];
|
||||
const optionalFields = [
|
||||
'customDocsPath',
|
||||
|
@ -36,6 +39,7 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
'docsUrl',
|
||||
'customFields',
|
||||
'githubHost',
|
||||
'algolia',
|
||||
];
|
||||
const missingFields = requiredFields.filter(field => !config[field]);
|
||||
if (missingFields && missingFields.length > 0) {
|
||||
|
@ -55,6 +59,30 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
}
|
||||
});
|
||||
|
||||
/* Build final headerLinks based on siteConfig */
|
||||
const {headerLinks} = config;
|
||||
// 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 => {
|
||||
// We will add search bar to end if location not specified
|
||||
if (link.search) {
|
||||
search = true;
|
||||
}
|
||||
});
|
||||
if (!search && config.algolia) {
|
||||
headerLinks.push({search: true});
|
||||
}
|
||||
config.headerLinks = headerLinks;
|
||||
|
||||
/*
|
||||
User's own array of custom fields,
|
||||
e.g: if they want to include some field so they can access it later from `props.siteConfig`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue