diff --git a/src/pages/api-doc/index.jsx b/src/pages/api-doc/index.jsx index 7c3a047f2..9f7e40e62 100644 --- a/src/pages/api-doc/index.jsx +++ b/src/pages/api-doc/index.jsx @@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react'; import Layout from '@theme/Layout'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import { useLocation } from 'react-router-dom'; @@ -10,30 +9,21 @@ import { useLocation } from 'react-router-dom'; function ApiDoc() { - const location = useLocation(); useEffect(() => { - console.log(location.pathname) - if (location.pathname === '/support/api-doc/') { - const removeAlternateLinks = () => { - const alternateLinks = document.querySelectorAll('link[rel="alternate"]'); - alternateLinks.forEach(link => link.parentNode.removeChild(link)); - }; - - removeAlternateLinks(); - - const observer = new MutationObserver((mutationsList) => { - for (const mutation of mutationsList) { - if (mutation.type === 'childList') { - removeAlternateLinks(); - } + const linkTag = ['link[rel="alternate"]']; + function addRoleAndTabIndexAttributes() { + linkTag.forEach(link => { + let alternateLinks = document.querySelectorAll(link); + console.log("in loop", alternateLinks) + for (let i = 0; i < alternateLinks.length; i++) { + const element = alternateLinks[i]; + element.remove(); } - }); - - observer.observe(document.body, { childList: true, subtree: true }); - - return () => observer.disconnect(); + + }) } - }, [location.pathname]); + addEventListener('load', addRoleAndTabIndexAttributes); + }, []); return (