Skip to content

Commit

Permalink
Add support for environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Jun 21, 2020
1 parent bcad685 commit 9d2fdfa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions components/page-footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const PageFooter = () => (
<li className='foot-header'>Contribute</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.addResources } target="_blank">Add resources</a></li>
<li><a href={ siteConfig.url.repo } target="_blank">Codebase</a></li>
<li><a href='/about'>About this Site</a></li>
</ul>
</div>
<div className="site-learn foot-col col-12 col-sm-4 col-lg-2">
Expand Down
1 change: 0 additions & 1 deletion components/site-nav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const SiteNav = () => (
<div className='nav-links'>
<a href='/roadmaps'>Roadmaps</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>
</div>

Expand Down
3 changes: 0 additions & 3 deletions config/dev.json

This file was deleted.

16 changes: 11 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ const { getPathMap } = require("./scripts/path-map");
const loadConfig = (env = 'dev') => {
const configPath = `./config/${env}.json`;
if (!fs.existsSync(configPath)) {
console.log(`Config file not found: ${configPath}`);
process.exit(1);
console.warn(`Config file not found: ${configPath}. Using environment variables only.`);
}

const appConfig = {};

console.log(`Config file found: ${configPath}`);
for (let key in process.env) {
if (!key.startsWith('ROADMAP_')) {
continue;
}

appConfig[key.replace('ROADMAP_', '')] = process.env[key];
}

// @todo stringify the values for webpack - it doesn't understand objects
return require(configPath);
return appConfig;
};

const options = {
Expand Down

0 comments on commit 9d2fdfa

Please sign in to comment.