mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Updated site url fetch from data attribute
closes https://github.com/TryGhost/members.js/issues/54 - Site url is added as data attribute on script tag load in Ghost head - was previously fetched via meta tag which was inserted on site
This commit is contained in:
parent
aaa8fd3535
commit
7a9d7497fb
1 changed files with 5 additions and 5 deletions
|
@ -12,10 +12,10 @@ function addRootDiv() {
|
||||||
document.body.appendChild(elem);
|
document.body.appendChild(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSiteUrlFromMeta() {
|
function getSiteUrl() {
|
||||||
const ghostSiteMeta = document.querySelector('meta[name="ghost:site"]');
|
const scriptTag = document.querySelector('script[data-ghost]');
|
||||||
if (ghostSiteMeta) {
|
if (scriptTag) {
|
||||||
return ghostSiteMeta.getAttribute('content');
|
return scriptTag.dataset.ghost;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ function setup({siteUrl}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
const siteUrl = getSiteUrlFromMeta() || window.location.origin;
|
const siteUrl = getSiteUrl() || window.location.origin;
|
||||||
setup({siteUrl});
|
setup({siteUrl});
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|
Loading…
Add table
Reference in a new issue