Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: make config available in index.html template
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
- Loading branch information
Showing
7 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
'@backstage/create-app': patch | ||
--- | ||
|
||
The `index.html` template of the app has been updated to use the new `config` global provided by the Backstage CLI. | ||
|
||
To apply this change to an existing app, make the following changes to `packages/app/public/index.html`: | ||
|
||
```diff | ||
- <title><%= app.title %></title> | ||
+ <title><%= config.getString('app.title') %></title> | ||
``` | ||
|
||
```diff | ||
- <% if (app.googleAnalyticsTrackingId && typeof app.googleAnalyticsTrackingId === 'string') { %> | ||
+ <% if (config.has('app.googleAnalyticsTrackingId')) { %> | ||
<script | ||
async | ||
- src="https://www.googletagmanager.com/gtag/js?id=<%= app.googleAnalyticsTrackingId %>" | ||
+ src="https://www.googletagmanager.com/gtag/js?id=<%= config.getString('app.googleAnalyticsTrackingId') %>" | ||
></script> | ||
``` | ||
|
||
```diff | ||
- gtag('config', '<%= app.googleAnalyticsTrackingId %>'); | ||
+ gtag( | ||
+ 'config', | ||
+ '<%= config.getString("app.googleAnalyticsTrackingId") %>', | ||
+ ); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
'@backstage/cli': patch | ||
--- | ||
|
||
The frontend configuration is now available as a `config` global during templating of the `index.html` file. This allows for much more flexibility as the values available during templating is not longer hardcoded to a fixed set of values. | ||
|
||
For example, to access the app title, you would now do the following: | ||
|
||
```html | ||
<title><%= config.getString('app.title') %></title> | ||
``` | ||
|
||
Along with this change, usage of the existing `app.<key>` values has been deprecated and will be removed in a future release. The general pattern for migrating existing usage is to replace `<%= app.<key> %>` with `<%= config.getString('app.<key>') %>`, although in some cases you may need to use for example `config.has('app.<key>')` or `config.getOptionalString('app.<key>')` instead. | ||
|
||
The [`@backstage/create-app` changelog](https://github.com/backstage/backstage/blob/master/packages/create-app/CHANGELOG.md#049) also contains more details how to migrate existing usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'embedded-techdocs-app': patch | ||
--- | ||
|
||
The `index.html` template was updated to use the new `config` global. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters