From d6ddcee39f8d238f00710727d0201f179db5d7d1 Mon Sep 17 00:00:00 2001 From: Tushar Sharma Date: Sun, 26 May 2019 01:59:43 +0530 Subject: [PATCH] fix: refactoring --- packages/docusaurus-1.x/lib/server/server.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/docusaurus-1.x/lib/server/server.js b/packages/docusaurus-1.x/lib/server/server.js index 28d346ea8d24..465ba7cfc658 100644 --- a/packages/docusaurus-1.x/lib/server/server.js +++ b/packages/docusaurus-1.x/lib/server/server.js @@ -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();