Skip to content

Commit

Permalink
fix: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharf5 committed May 25, 2019
1 parent 09cd2fa commit d6ddcee
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/docusaurus-1.x/lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,17 @@ function execute(port, host) {
next();
return;
}
const extractedMetadata = metadataUtils.extractMetadata(file);
const rawContent = extractedMetadata.rawContent;
const rawMetadata = extractedMetadata.metadata;
const {rawContent, metadata: rawMetadata} = metadataUtils.extractMetadata(
file,
);

// if any of the followings is changed, reload the metadata
const reloadTriggers = ['sidebar_label', 'hide_title', 'title'];
for (let i = 0; i < reloadTriggers.length; i++) {
const key = reloadTriggers[i];
if (metadata[key] !== rawMetadata[key]) {
reloadMetadata();
extractTranslations();
reloadTranslations();
metadata = Metadata[metakey];
break;
}
if (reloadTriggers.some(key => metadata[key] !== rawMetadata[key])) {
reloadMetadata();
extractTranslations();
reloadTranslations();
metadata = Metadata[metakey];
}

reloadSiteConfig();
Expand Down

0 comments on commit d6ddcee

Please sign in to comment.