You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-07-15 01:34:30 +02:00
Update Layout.js
This commit is contained in:
@ -15,39 +15,37 @@ export default function CustomLayout(props) {
|
|||||||
// Удаляем предыдущий блок и скрипт, если они существуют
|
// Удаляем предыдущий блок и скрипт, если они существуют
|
||||||
const existingAdContainer = document.getElementById('yandex_rtb_R-A-12294791-5');
|
const existingAdContainer = document.getElementById('yandex_rtb_R-A-12294791-5');
|
||||||
if (existingAdContainer) {
|
if (existingAdContainer) {
|
||||||
existingAdContainer.remove();
|
existingAdContainer.innerHTML = ''; // Очищаем контейнер перед перерендерингом
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создаем контейнер для второго рекламного блока
|
// Создаем контейнер для второго рекламного блока, если он не существует
|
||||||
const adContainer = document.createElement('div');
|
let adContainer = existingAdContainer;
|
||||||
adContainer.id = 'yandex_rtb_R-A-12294791-5';
|
if (!adContainer) {
|
||||||
adContainer.style.marginTop = '20px'; // Добавим отступ для красоты
|
adContainer = document.createElement('div');
|
||||||
|
adContainer.id = 'yandex_rtb_R-A-12294791-5';
|
||||||
|
adContainer.style.marginTop = '20px'; // Добавим отступ для красоты
|
||||||
|
|
||||||
// Находим элемент кнопок "Previous" и "Next" и вставляем перед ним
|
// Находим элемент кнопок "Previous" и "Next" и вставляем перед ним
|
||||||
const paginationElement = document.querySelector('.pagination-nav');
|
const paginationElement = document.querySelector('.pagination-nav');
|
||||||
if (paginationElement) {
|
if (paginationElement) {
|
||||||
paginationElement.parentNode.insertBefore(adContainer, paginationElement);
|
paginationElement.parentNode.insertBefore(adContainer, paginationElement);
|
||||||
} else {
|
} else {
|
||||||
// Если кнопок нет, добавляем контейнер в конец body
|
// Если кнопок нет, добавляем контейнер в конец body
|
||||||
document.body.appendChild(adContainer);
|
document.body.appendChild(adContainer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создаем скрипт для рендеринга рекламы
|
// Создаем скрипт для рендеринга рекламы
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.innerHTML = `
|
script.innerHTML = `
|
||||||
window.yaContextCb.push(() => {
|
window.yaContextCb.push(() => {
|
||||||
|
Ya.Context.AdvManager.destroy('yandex_rtb_R-A-12294791-5'); // Удаляем предыдущий экземпляр блока
|
||||||
Ya.Context.AdvManager.render({
|
Ya.Context.AdvManager.render({
|
||||||
"blockId": "R-A-12294791-3",
|
"blockId": "R-A-12294791-3",
|
||||||
"type": "floorAd",
|
"type": "floorAd",
|
||||||
"platform": "touch"
|
"platform": "touch"
|
||||||
});
|
});
|
||||||
|
|
||||||
Ya.Context.AdvManager.render({
|
|
||||||
"blockId": "R-A-12294791-4",
|
|
||||||
"type": "floorAd",
|
|
||||||
"platform": "desktop"
|
|
||||||
});
|
|
||||||
|
|
||||||
Ya.Context.AdvManager.render({
|
Ya.Context.AdvManager.render({
|
||||||
"blockId": "R-A-12294791-5",
|
"blockId": "R-A-12294791-5",
|
||||||
"renderTo": "yandex_rtb_R-A-12294791-5"
|
"renderTo": "yandex_rtb_R-A-12294791-5"
|
||||||
@ -59,7 +57,7 @@ export default function CustomLayout(props) {
|
|||||||
// Удаляем элементы при размонтировании компонента
|
// Удаляем элементы при размонтировании компонента
|
||||||
return () => {
|
return () => {
|
||||||
script.remove();
|
script.remove();
|
||||||
adContainer.remove();
|
adContainer.innerHTML = ''; // Очищаем контейнер при размонтировании
|
||||||
};
|
};
|
||||||
}, [location.pathname]); // Перезапуск эффекта при изменении пути
|
}, [location.pathname]); // Перезапуск эффекта при изменении пути
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user