Add support for environment variables

pull/1331/head
Kamran Ahmed 4 years ago
parent bcad685e27
commit 9d2fdfa7cf
  1. 3
      components/page-footer/index.js
  2. 1
      components/site-nav/index.js
  3. 3
      config/dev.json
  4. 16
      next.config.js

@ -29,8 +29,7 @@ const PageFooter = () => (
<li className='foot-header'>Contribute</li> <li className='foot-header'>Contribute</li>
<li><a href={ siteConfig.url.addGuide } target="_blank">Write a Guide</a></li> <li><a href={ siteConfig.url.addGuide } target="_blank">Write a Guide</a></li>
<li><a href={ siteConfig.url.addRoadmap } target="_blank">Submit a Roadmap</a></li> <li><a href={ siteConfig.url.addRoadmap } target="_blank">Submit a Roadmap</a></li>
<li><a href={ siteConfig.url.addResources } target="_blank">Add resources</a></li> <li><a href='/about'>About this Site</a></li>
<li><a href={ siteConfig.url.repo } target="_blank">Codebase</a></li>
</ul> </ul>
</div> </div>
<div className="site-learn foot-col col-12 col-sm-4 col-lg-2"> <div className="site-learn foot-col col-12 col-sm-4 col-lg-2">

@ -11,7 +11,6 @@ const SiteNav = () => (
<div className='nav-links'> <div className='nav-links'>
<a href='/roadmaps'>Roadmaps</a> <a href='/roadmaps'>Roadmaps</a>
<a href='/guides'>Guides</a> <a href='/guides'>Guides</a>
<a href='/about' className='d-none d-md-inline-block'>FAQ</a>
<a href='/signup' className='d-none d-md-inline-block'>Subscribe</a> <a href='/signup' className='d-none d-md-inline-block'>Subscribe</a>
</div> </div>

@ -1,3 +0,0 @@
{
"GA_SECRET": ""
}

@ -20,14 +20,20 @@ const { getPathMap } = require("./scripts/path-map");
const loadConfig = (env = 'dev') => { const loadConfig = (env = 'dev') => {
const configPath = `./config/${env}.json`; const configPath = `./config/${env}.json`;
if (!fs.existsSync(configPath)) { if (!fs.existsSync(configPath)) {
console.log(`Config file not found: ${configPath}`); console.warn(`Config file not found: ${configPath}. Using environment variables only.`);
process.exit(1);
} }
console.log(`Config file found: ${configPath}`); const appConfig = {};
// @todo stringify the values for webpack - it doesn't understand objects for (let key in process.env) {
return require(configPath); if (!key.startsWith('ROADMAP_')) {
continue;
}
appConfig[key.replace('ROADMAP_', '')] = process.env[key];
}
return appConfig;
}; };
const options = { const options = {

Loading…
Cancel
Save