0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Updated comment box location

This commit is contained in:
Simon Backx 2022-07-04 16:11:53 +02:00
parent aeb644cf84
commit fccc18f51c

View file

@ -5,16 +5,24 @@ import './index.css';
const ROOT_DIV_ID = 'ghost-comments-root'; const ROOT_DIV_ID = 'ghost-comments-root';
function addRootDiv() { function addRootDiv() {
const elem = document.createElement('div'); const scriptTag = document.querySelector('script[data-ghost-comments]');
elem.id = ROOT_DIV_ID;
document.body.appendChild(elem); // 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 {
// eslint-disable-next-line no-console
console.warn('Comment box location was not found: could not load comments box.');
}
} }
function getSiteData() { function getSiteData() {
/** /**
* @type {HTMLElement} * @type {HTMLElement}
*/ */
const scriptTag = document.querySelector('script[data-ghost]'); const scriptTag = document.querySelector('script[data-ghost-comments]');
if (scriptTag) { if (scriptTag) {
const siteUrl = scriptTag.dataset.ghost; const siteUrl = scriptTag.dataset.ghost;
const apiKey = scriptTag.dataset.key; const apiKey = scriptTag.dataset.key;