@theguild/components
Version:
22 lines (21 loc) • 613 B
JavaScript
"use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
const AttachPageFAQSchema = ({ faqPages }) => {
const pathname = usePathname();
useEffect(() => {
const html = document.querySelector("html");
if (faqPages.includes(pathname) && !html.hasAttribute("itemscope")) {
html.setAttribute("itemscope", "");
html.setAttribute("itemtype", "https://schema.org/FAQPage");
return () => {
html.removeAttribute("itemscope");
html.removeAttribute("itemtype");
};
}
}, []);
return null;
};
export {
AttachPageFAQSchema
};