Add custom title to React UI (#7607)
* Backport custom title to React UI Backports #4841 into the new UI. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu> * Fix typo Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
cfe30a7b62
commit
a3ac9fa5f5
|
@ -37,7 +37,11 @@
|
|||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Prometheus Expression Browser</title>
|
||||
<!--
|
||||
The TITLE_PLACEHOLDER magic value is replaced during serving by Prometheus.
|
||||
We need it dynamic because it can be overriden by the command line flag `web.page-title`.
|
||||
-->
|
||||
<title>TITLE_PLACEHOLDER</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
|
|
@ -396,9 +396,10 @@ func New(logger log.Logger, o *Options) *Handler {
|
|||
fmt.Fprintf(w, "Error reading React index.html: %v", err)
|
||||
return
|
||||
}
|
||||
prefixedIdx := bytes.ReplaceAll(idx, []byte("PATH_PREFIX_PLACEHOLDER"), []byte(o.ExternalURL.Path))
|
||||
prefixedIdx = bytes.ReplaceAll(prefixedIdx, []byte("CONSOLES_LINK_PLACEHOLDER"), []byte(h.consolesPath()))
|
||||
w.Write(prefixedIdx)
|
||||
replacedIdx := bytes.ReplaceAll(idx, []byte("PATH_PREFIX_PLACEHOLDER"), []byte(o.ExternalURL.Path))
|
||||
replacedIdx = bytes.ReplaceAll(replacedIdx, []byte("CONSOLES_LINK_PLACEHOLDER"), []byte(h.consolesPath()))
|
||||
replacedIdx = bytes.ReplaceAll(replacedIdx, []byte("TITLE_PLACEHOLDER"), []byte(h.options.PageTitle))
|
||||
w.Write(replacedIdx)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue