I have a jade page, and the first thing I do is set a variable which determines the base directory used by all links.
if ! base
base = '/klog/'
// base = '/website-clear/klog/'
This is actually for a github page, so every time I render the page to html, I have to remember to change the base, and then change it back again for local editing.
There must be a better way of doing it. Currently I am thinking to have an untracked file in the local copy, that includes the base - but is that really necessary?
What is the best way to handle this issue?
A more robust solution would be checking for environment variables.
Have NODE_ENV=production
set on the production server, and do not set it on the dev server.
Then in your jade template, render different paths if the environment variable exists.
if 'production' == process.env.NODE_ENV
- base = '/website-clear/klog/'
or
- base = ( 'production' == process.env.NODE_ENV ? '/website-clear/klog/' : '/klog' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With