From 77bb21b17635e0be28eb90f09b057d14f5765b95 Mon Sep 17 00:00:00 2001 From: ishavyas9 Date: Tue, 15 Oct 2024 16:31:34 +0530 Subject: [PATCH] remove hreflang from APi-doc page --- src/pages/api-doc/index.jsx | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) 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 (