mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-13 00:03:57 +02:00
chore: naming consistency
This commit is contained in:
parent
5eab627340
commit
c132c7445f
11 changed files with 62 additions and 56 deletions
|
@ -7,10 +7,10 @@ const {getSubFolder, idx} = require('../utils');
|
|||
|
||||
async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
||||
// @tested - load all sidebars including versioned sidebars
|
||||
const allSidebars = loadSidebars({siteDir, env});
|
||||
const docsSidebars = loadSidebars({siteDir, env});
|
||||
|
||||
// @tested - build the docs ordering such as next, previous, category and sidebar
|
||||
const order = createOrder(allSidebars);
|
||||
const order = createOrder(docsSidebars);
|
||||
|
||||
/* Settle versions & translations from environment */
|
||||
const translationEnabled = idx(env, ['translation', 'enabled']);
|
||||
|
@ -24,7 +24,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
(versioningEnabled && idx(env, ['versioning', 'versions'])) || [];
|
||||
|
||||
/* Prepare metadata container */
|
||||
const metadatas = {};
|
||||
const docsMetadatas = {};
|
||||
|
||||
/* metadata for default docs files */
|
||||
const docsFiles = await globby(['**/*.md'], {
|
||||
|
@ -49,7 +49,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
order,
|
||||
siteConfig
|
||||
);
|
||||
metadatas[metadata.id] = metadata;
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -80,7 +80,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
order,
|
||||
siteConfig
|
||||
);
|
||||
metadatas[metadata.id] = metadata;
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -98,27 +98,30 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
order,
|
||||
siteConfig
|
||||
);
|
||||
metadatas[metadata.id] = metadata;
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
);
|
||||
|
||||
/*
|
||||
Get the titles of the previous and next ids so that we can use them
|
||||
*/
|
||||
Object.keys(metadatas).forEach(currentID => {
|
||||
const previousID = idx(metadatas, [currentID, 'previous']);
|
||||
Object.keys(docsMetadatas).forEach(currentID => {
|
||||
const previousID = idx(docsMetadatas, [currentID, 'previous']);
|
||||
if (previousID) {
|
||||
const previousTitle = idx(metadatas, [previousID, 'title']);
|
||||
metadatas[currentID].previous_title = previousTitle || 'Previous';
|
||||
const previousTitle = idx(docsMetadatas, [previousID, 'title']);
|
||||
docsMetadatas[currentID].previous_title = previousTitle || 'Previous';
|
||||
}
|
||||
const nextID = idx(metadatas, [currentID, 'next']);
|
||||
const nextID = idx(docsMetadatas, [currentID, 'next']);
|
||||
if (nextID) {
|
||||
const nextTitle = idx(metadatas, [nextID, 'title']);
|
||||
metadatas[currentID].next_title = nextTitle || 'Next';
|
||||
const nextTitle = idx(docsMetadatas, [nextID, 'title']);
|
||||
docsMetadatas[currentID].next_title = nextTitle || 'Next';
|
||||
}
|
||||
});
|
||||
|
||||
return metadatas;
|
||||
return {
|
||||
docsSidebars,
|
||||
docsMetadatas
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = loadDocs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue