From f87afd70c1a4fb80c8173e559ff8975705dcdd79 Mon Sep 17 00:00:00 2001 From: Anton Titovets Date: Thu, 10 Oct 2024 10:29:30 +0300 Subject: [PATCH] Update Layout.js --- docs/docusaurus/src/theme/Layout.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/docusaurus/src/theme/Layout.js b/docs/docusaurus/src/theme/Layout.js index dee45fd7bf..5cb50de2bc 100644 --- a/docs/docusaurus/src/theme/Layout.js +++ b/docs/docusaurus/src/theme/Layout.js @@ -1,11 +1,21 @@ import React, { useEffect } from 'react'; import Layout from '@theme-original/Layout'; import Head from '@docusaurus/Head'; +import { useLocation } from '@docusaurus/router'; export default function CustomLayout(props) { + const location = useLocation(); + useEffect(() => { + // Проверяем, находимся ли мы на странице документации if (!location.pathname.startsWith('/docs/')) { - return; // Если не на странице документации, не добавляем блок + return; // Если нет, не добавляем блок + } + + // Удаляем предыдущий блок и скрипт, если они существуют + const existingAdContainer = document.getElementById('yandex_rtb_R-A-12294791-5'); + if (existingAdContainer) { + existingAdContainer.remove(); } // Создаем контейнер для второго рекламного блока @@ -51,7 +61,7 @@ export default function CustomLayout(props) { script.remove(); adContainer.remove(); }; - }, []); + }, [location.pathname]); // Перезапуск эффекта при изменении пути return ( <>