openpanel/documentation/src/utils/link-rel.ts
2024-02-05 10:23:04 +01:00

25 lines
623 B
TypeScript

import isInternalUrl from "@docusaurus/isInternalUrl";
/**
* This function will generate rel attribute for links.
* @param {string} URL to be dest for link
*/
export const getLinkRel = (URL?: string): string => {
let rel = "noopener noreferrer nofollow";
const isInternalURL = isInternalUrl(URL);
if (URL?.includes("github.com/refinedev/refine")) {
rel = "noopener";
}
if (isInternalURL || URL?.includes("refine.dev")) {
rel = "noopener dofollow";
}
if (isInternalURL || URL?.includes("reactadminpanel.com")) {
rel = "noopener dofollow";
}
return rel;
};