Skip to content

Commit

Permalink
add-on to inject base URL into index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lizkrznarich committed Jan 5, 2023
1 parent ae2592e commit e9c0d59
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
API_URL=https://api.dev.ror.org
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://dev.ror.org
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
API_URL=https://api.ror.org
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://ror.org
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
API_URL=https://api.staging.ror.org
SENTRY_DSN=https://[email protected]/1422597
BASE_URL=https://staging.ror.org
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<link rel="stylesheet" href="{{rootURL}}assets/vendor.css" type='text/css'>

<link rel="stylesheet" href="https://ror.org/css/hugo-ror.css?v4">
<link rel="stylesheet" href="{{content-for 'baseURL'}}/css/hugo-ror.css?v4">
<link rel="stylesheet" href="{{rootURL}}assets/ror-app.css" type='text/css'>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
Expand Down
3 changes: 2 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = function(environment) {
const pkg = require('../package.json');

let ENV = {
modulePrefix: 'ror-app',
environment,
Expand All @@ -20,6 +20,7 @@ module.exports = function(environment) {
},

API_URL: process.env.API_URL || "https://api.ror.org",
BASE_URL: process.env.BASE_URL || null,
SENTRY_DSN: process.env.SENTRY_DSN || null,
VERSION: pkg.version,
APP_NAME: pkg.name,
Expand Down
15 changes: 15 additions & 0 deletions lib/base-url/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
name: require('./package').name,

isDevelopingAddon() {
return true;
},
contentFor: function(type, config){
if (type === 'baseURL'){
return `${config.BASE_URL}`
;
}
}
};
6 changes: 6 additions & 0 deletions lib/base-url/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "base-url",
"keywords": [
"ember-addon"
]
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@
"dependencies": {
"@sentry/browser": "^5.10.2",
"@sentry/integrations": "^5.10.2"
},
"ember-addon": {
"paths": [
"lib/base-url"
]
}
}

0 comments on commit e9c0d59

Please sign in to comment.