mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
fork refine
This commit is contained in:
24
documentation/src/utils/link-rel.ts
Normal file
24
documentation/src/utils/link-rel.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
};
|
||||
5
documentation/src/utils/open-figma.ts
Normal file
5
documentation/src/utils/open-figma.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const openFigma = () => {
|
||||
return window
|
||||
.open("https://openpanel.co/contact", "_blank")
|
||||
?.focus();
|
||||
};
|
||||
28
documentation/src/utils/split-code.ts
Normal file
28
documentation/src/utils/split-code.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
type SplitReturn = {
|
||||
visible: string;
|
||||
join: (code: string) => string;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function will split code by the visible-block-start and visible-block-end comments and returns the visible block and join function.
|
||||
* @param {string} code to be splitted by `// visible-block-start` and `// visible-block-end`
|
||||
*/
|
||||
export const splitCode = (code?: string): SplitReturn => {
|
||||
const beginningComment = "// visible-block-start";
|
||||
const endingComment = "// visible-block-end";
|
||||
|
||||
let beginning = code.indexOf(beginningComment);
|
||||
beginning = beginning > 0 ? beginning + beginningComment.length : 0;
|
||||
|
||||
let ending = code.indexOf(endingComment);
|
||||
ending = ending > 0 ? ending : code.length;
|
||||
|
||||
const aboveHidden = code.slice(0, beginning);
|
||||
const visible = code.slice(beginning, ending).trimEnd().trimStart();
|
||||
const belowHidden = code.slice(ending);
|
||||
|
||||
return {
|
||||
visible,
|
||||
join: (code: string) => `${aboveHidden}\n${code}\n${belowHidden}`,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user