Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

How to configure docusaurus config keys conditionally?

$
0
0

If a user needs to configure an optional docusaurus config key based on some condition, what is the best way to address it in docusaurus.config.js file? For example:

module.exports = {  /* If condition is true then */  showLastUpdateAuthor: true,  /* otherwise set it to false */  //Other config key value...}

Here is what I tried and it worked. Is there a better way to handle this?Insights via Spread Syntax discussed here.

const branch = require('child_process')  .execSync('git branch --show-current')  .toString().trim();module.exports = {    ...(branch != 'main') ? {showLastUpdateAuthor: true,}:{showLastUpdateAuthor: false,},    //Other config key value...}

Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>