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}); +}