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);
|
||||
}
|
||||
|
||||
function getSiteUrlFromMeta() {
|
||||
const ghostSiteMeta = document.querySelector('meta[name="ghost:site"]');
|
||||
if (ghostSiteMeta) {
|
||||
return ghostSiteMeta.getAttribute('content');
|
||||
function getSiteUrl() {
|
||||
const scriptTag = document.querySelector('script[data-ghost]');
|
||||
if (scriptTag) {
|
||||
return scriptTag.dataset.ghost;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ function setup({siteUrl}) {
|
|||
}
|
||||
|
||||
function init() {
|
||||
const siteUrl = getSiteUrlFromMeta() || window.location.origin;
|
||||
const siteUrl = getSiteUrl() || window.location.origin;
|
||||
setup({siteUrl});
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
|
|
Loading…
Add table
Reference in a new issue