From 17bd13446b17a6c2e88b4eabe0943b14f2141793 Mon Sep 17 00:00:00 2001 From: Serafeim Chatzopoulos Date: Mon, 12 Dec 2022 09:35:53 +0200 Subject: [PATCH] Add support for ENV variables --- .env | 2 ++ docusaurus.config.js | 14 ++++++++++++-- package-lock.json | 14 ++++++++++++++ package.json | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..9ed2036 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +URL="http://snf-23385.ok-kno.grnetcloud.net" +BASE_URL="/" diff --git a/docusaurus.config.js b/docusaurus.config.js index 93923a7..d546833 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -6,13 +6,23 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula'); const math = require('remark-math'); const katex = require('rehype-katex'); const { filterItems } = require('./sidebar-utils'); +const dotenv = require('dotenv'); + +// load env variables (see .env file) +const env = dotenv.config(); +if (env.error) { + throw env.error; +} + +console.info("ENV VARIABLES:"); +console.info(env.parsed); /** @type {import('@docusaurus/types').Config} */ const config = { title: 'OpenAIRE Documentation', tagline: 'Open Access Infrastructure for Research in Europe', - url: 'http://snf-23385.ok-kno.grnetcloud.net', - baseUrl: '/', // serve the website at route + url: process.env.URL, + baseUrl: process.env.BASE_URL, // serve the website at route onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'warn', favicon: 'img/favicon.ico', diff --git a/package-lock.json b/package-lock.json index 7203b12..6ef2d92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@docusaurus/preset-classic": "^2.2.0", "@mdx-js/react": "^1.6.22", "clsx": "^1.2.1", + "dotenv": "^16.0.3", "hast-util-is-element": "^1.1.0", "prism-react-renderer": "^1.3.5", "react": "^17.0.2", @@ -5422,6 +5423,14 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "engines": { + "node": ">=12" + } + }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -16363,6 +16372,11 @@ } } }, + "dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==" + }, "duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", diff --git a/package.json b/package.json index e022bb7..80eff8b 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@docusaurus/preset-classic": "^2.2.0", "@mdx-js/react": "^1.6.22", "clsx": "^1.2.1", + "dotenv": "^16.0.3", "hast-util-is-element": "^1.1.0", "prism-react-renderer": "^1.3.5", "react": "^17.0.2",