0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fixed commentbox not injected

This commit is contained in:
Peter Zimon 2022-07-05 11:34:51 +02:00
parent eb10f02e5f
commit 1504e84c7e

View file

@ -7,20 +7,18 @@ const ROOT_DIV_ID = 'ghost-comments-root';
function addRootDiv() { function addRootDiv() {
const scriptTag = document.querySelector('script[data-ghost-comments]'); const scriptTag = document.querySelector('script[data-ghost-comments]');
if (process.env.NODE_ENV === 'development') { // We need to inject the comment box at the same place as the script tag
if (scriptTag) {
const elem = document.createElement('div');
elem.id = ROOT_DIV_ID;
scriptTag.parentElement.insertBefore(elem, scriptTag);
} else if (process.env.NODE_ENV === 'development') {
const elem = document.createElement('div'); const elem = document.createElement('div');
elem.id = ROOT_DIV_ID; elem.id = ROOT_DIV_ID;
document.body.appendChild(elem); document.body.appendChild(elem);
} else { } else {
// We need to inject the comment box at the same place as the script tag // eslint-disable-next-line no-console
if (scriptTag) { console.warn('Comment box location was not found: could not load comments box.');
const elem = document.createElement('div');
elem.id = ROOT_DIV_ID;
scriptTag.parentElement.insertBefore(elem, scriptTag);
} else {
// eslint-disable-next-line no-console
console.warn('Comment box location was not found: could not load comments box.');
}
} }
} }