From c3d13f2451e521fcd5731db3e9b9d7c0e56fb05c Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 10 Apr 2020 17:37:40 +0100 Subject: [PATCH] Added local dev env configuration - call init by default if there's an env var for ADMIN_URL - add an example local dev config --- ghost/portal/.env.local.example | 2 ++ ghost/portal/README.md | 8 +++++++- ghost/portal/src/index.js | 12 +++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 ghost/portal/.env.local.example diff --git a/ghost/portal/.env.local.example b/ghost/portal/.env.local.example new file mode 100644 index 0000000000..09883d6b86 --- /dev/null +++ b/ghost/portal/.env.local.example @@ -0,0 +1,2 @@ +REACT_APP_ADMIN_URL=http://localhost:2368/ghost +REACT_APP_SITE_URL=http://localhost:2368 diff --git a/ghost/portal/README.md b/ghost/portal/README.md index 4c876bf4c9..d73c895aae 100644 --- a/ghost/portal/README.md +++ b/ghost/portal/README.md @@ -1,7 +1,13 @@ -# Membersjs +# Members.js This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +## Configure for local development + +- Copy `.env.local.example` to `.env.local` +- Update the values to match your local dev version of Ghost +- Ensure your local Ghost is running + ## Available Scripts In the project directory, you can run: diff --git a/ghost/portal/src/index.js b/ghost/portal/src/index.js index 1c7eafd66f..6e36ff3906 100644 --- a/ghost/portal/src/index.js +++ b/ghost/portal/src/index.js @@ -12,9 +12,15 @@ function initMembersJS(data) { ); } -// Uncomment for local UI testing -// initMembersJS({site: {siteUrl: "", adminUrl: ""}}); - window.GhostMembers = { initMembersJS: initMembersJS }; + +// This will automatically load for local if an .env.local file is present +if (process.env.REACT_APP_ADMIN_URL) { + let site = { + adminUrl: process.env.REACT_APP_ADMIN_URL, + siteUrl: process.env.REACT_APP_SITE_URL || process.env.REACT_APP_ADMIN_URL + }; + initMembersJS({site}); +}