Skip to content

Commit

Permalink
Build pages with environmental variables from .env. (#168)
Browse files Browse the repository at this point in the history
* Build pages with environmental variables from .env.

---------

Co-authored-by: Adam J. Arling <[email protected]>
Co-authored-by: mat <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent 3607721 commit 0813e2b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_URL = "https://canopy-iiif.vercel.app"
NEXT_PUBLIC_BASE_PATH = ""
NEXT_PUBLIC_URL="https://canopy-iiif.github.io"
NEXT_PUBLIC_BASE_PATH="/canopy-iiif"
10 changes: 6 additions & 4 deletions .github/workflows/gh-pages.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ jobs:
build:
runs-on: ubuntu-latest

env:
NEXT_PUBLIC_URL: https://canopy-iiif.github.io
NEXT_PUBLIC_BASE_PATH: /canopy-iiif

strategy:
matrix:
node-version: [18.x]
Expand All @@ -25,6 +21,12 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Load NEXT_PUBLIC_URL and NEXT_PUBLIC_BASE_PATH from .env
run: |
set -o allexport
source .env
set +o allexport
- name: Install
run: npm ci

Expand Down
2 changes: 1 addition & 1 deletion canopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const args = process.argv;
const config = buildConfig.getConfig(path, isDev);

const url = isDev ? `http://localhost:5001` : process.env.NEXT_PUBLIC_URL;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
const basePath = isDev ? `` : process.env.NEXT_PUBLIC_BASE_PATH;
const baseUrl = basePath ? `${url}${basePath}` : url;

const env = {
Expand Down
5 changes: 2 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ module.exports = (phase) => {
const config = getConfig(undefined, isDev);

const url = isDev ? `http://localhost:5001` : process.env.NEXT_PUBLIC_URL;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
const basePath = isDev ? `` : process.env.NEXT_PUBLIC_BASE_PATH;
const baseUrl = basePath ? `${url}${basePath}` : url;

const env = {
CANOPY_CONFIG: {
...config,
url,
assetPrefix: basePath,
basePath,
baseUrl,
},
Expand All @@ -31,8 +32,6 @@ module.exports = (phase) => {

return {
env,
assetPrefix: process.env.NEXT_PUBLIC_BASE_PATH,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
redirects,
typescript: {
Expand Down

0 comments on commit 0813e2b

Please sign in to comment.