|
@@ -3,6 +3,8 @@ import dynamic from "next/dynamic";
|
|
import Head from "next/head";
|
|
import Head from "next/head";
|
|
import { materialDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
import { materialDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
|
|
+import { Footer } from "src/components/Footer";
|
|
|
|
+import { Button } from "src/components/Button";
|
|
|
|
|
|
const SyntaxHighlighter = dynamic(
|
|
const SyntaxHighlighter = dynamic(
|
|
() => import("react-syntax-highlighter").then(c => c.PrismAsync),
|
|
() => import("react-syntax-highlighter").then(c => c.PrismAsync),
|
|
@@ -29,13 +31,15 @@ const StyledContent = styled.section`
|
|
border-radius: 6px;
|
|
border-radius: 6px;
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
+const StyledDescription = styled.div``;
|
|
|
|
+
|
|
const StyledContentBody = styled.div`
|
|
const StyledContentBody = styled.div`
|
|
display: flex;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
flex-wrap: wrap;
|
|
gap: 15px;
|
|
gap: 15px;
|
|
line-height: 1.8;
|
|
line-height: 1.8;
|
|
|
|
|
|
- p {
|
|
|
|
|
|
+ ${StyledDescription} {
|
|
flex: 1;
|
|
flex: 1;
|
|
}
|
|
}
|
|
`;
|
|
`;
|
|
@@ -52,123 +56,128 @@ const StyledHighlight = styled.span<{ link?: boolean; alert?: boolean }>`
|
|
margin: ${({ alert }) => alert && "8px 0"};
|
|
margin: ${({ alert }) => alert && "8px 0"};
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
+
|
|
const Docs = () => {
|
|
const Docs = () => {
|
|
return (
|
|
return (
|
|
- <StyledPage>
|
|
|
|
|
|
+ <>
|
|
<Head>
|
|
<Head>
|
|
<title>Creating JSON Crack Embed | JSON Crack</title>
|
|
<title>Creating JSON Crack Embed | JSON Crack</title>
|
|
<meta name="description" content="Embedding JSON Crack tutorial into your websites." />
|
|
<meta name="description" content="Embedding JSON Crack tutorial into your websites." />
|
|
</Head>
|
|
</Head>
|
|
- <h1>Embed</h1>
|
|
|
|
- <StyledContent>
|
|
|
|
- <h2># Fetching from URL</h2>
|
|
|
|
- <StyledContentBody>
|
|
|
|
- <p>
|
|
|
|
- By adding <StyledHighlight>?json=https://catfact.ninja/fact</StyledHighlight> query at
|
|
|
|
- the end of iframe src you will be able to fetch from URL at widgets without additional
|
|
|
|
- scripts. This applies to editor page as well, the following link will fetch the url at
|
|
|
|
- the editor:{" "}
|
|
|
|
- <StyledHighlight
|
|
|
|
- as="a"
|
|
|
|
- href="https://jsoncrack.com/editor?json=https://catfact.ninja/fact"
|
|
|
|
- link
|
|
|
|
- >
|
|
|
|
- https://jsoncrack.com/editor?json=https://catfact.ninja/fact
|
|
|
|
- </StyledHighlight>
|
|
|
|
- </p>
|
|
|
|
|
|
+ <StyledPage>
|
|
|
|
+ <Button href="/" link status="SECONDARY">< Go Back</Button>
|
|
|
|
+ <h1>Documentation</h1>
|
|
|
|
+ <StyledContent>
|
|
|
|
+ <h2># Fetching from URL</h2>
|
|
|
|
+ <StyledContentBody>
|
|
|
|
+ <StyledDescription>
|
|
|
|
+ By adding <StyledHighlight>?json=https://catfact.ninja/fact</StyledHighlight> query at
|
|
|
|
+ the end of iframe src you will be able to fetch from URL at widgets without additional
|
|
|
|
+ scripts. This applies to editor page as well, the following link will fetch the url at
|
|
|
|
+ the editor:{" "}
|
|
|
|
+ <StyledHighlight
|
|
|
|
+ as="a"
|
|
|
|
+ href="https://jsoncrack.com/editor?json=https://catfact.ninja/fact"
|
|
|
|
+ link
|
|
|
|
+ >
|
|
|
|
+ https://jsoncrack.com/editor?json=https://catfact.ninja/fact
|
|
|
|
+ </StyledHighlight>
|
|
|
|
+ </StyledDescription>
|
|
|
|
|
|
- <StyledFrame
|
|
|
|
- scrolling="no"
|
|
|
|
- title="Untitled"
|
|
|
|
- src="https://codepen.io/AykutSarac/embed/KKBpWVR?default-tab=html%2Cresult"
|
|
|
|
- loading="eager"
|
|
|
|
- >
|
|
|
|
- See the Pen <a href="https://codepen.io/AykutSarac/pen/KKBpWVR">Untitled</a> by Aykut
|
|
|
|
- Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
- <a href="https://codepen.io">CodePen</a>.
|
|
|
|
- </StyledFrame>
|
|
|
|
- </StyledContentBody>
|
|
|
|
- </StyledContent>
|
|
|
|
- <StyledContent>
|
|
|
|
- <h2># Embed Saved JSON</h2>
|
|
|
|
- <StyledContentBody>
|
|
|
|
- <p>
|
|
|
|
- Just like fetching from URL above, you can embed saved public json by adding the json id
|
|
|
|
- to "json" query{" "}
|
|
|
|
- <StyledHighlight>?json=639b65c5a82efc29a24b2de2</StyledHighlight>
|
|
|
|
- </p>
|
|
|
|
- <StyledFrame
|
|
|
|
- scrolling="no"
|
|
|
|
- title="Untitled"
|
|
|
|
- src="https://codepen.io/AykutSarac/embed/vYaORgM?default-tab=html%2Cresult"
|
|
|
|
- loading="lazy"
|
|
|
|
- >
|
|
|
|
- See the Pen <a href="https://codepen.io/AykutSarac/pen/vYaORgM">Untitled</a> by Aykut
|
|
|
|
- Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
- <a href="https://codepen.io">CodePen</a>.
|
|
|
|
- </StyledFrame>
|
|
|
|
- </StyledContentBody>
|
|
|
|
- </StyledContent>
|
|
|
|
- <StyledContent>
|
|
|
|
- <h2># Communicating with API</h2>
|
|
|
|
- <h3>◼︎ Post Message to Embed</h3>
|
|
|
|
- <StyledContentBody>
|
|
|
|
- <p>
|
|
|
|
- Communicating with the embed is possible with{" "}
|
|
|
|
- <StyledHighlight
|
|
|
|
- as="a"
|
|
|
|
- href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage"
|
|
|
|
- link
|
|
|
|
|
|
+ <StyledFrame
|
|
|
|
+ scrolling="no"
|
|
|
|
+ title="Untitled"
|
|
|
|
+ src="https://codepen.io/AykutSarac/embed/KKBpWVR?default-tab=html%2Cresult"
|
|
|
|
+ loading="eager"
|
|
>
|
|
>
|
|
- MessagePort
|
|
|
|
- </StyledHighlight>
|
|
|
|
- , you should pass an object consist of "json" and "options" key
|
|
|
|
- where json is a string and options is an object that may contain the following:
|
|
|
|
- <SyntaxHighlighter language="markdown" style={materialDark} showLineNumbers={true}>
|
|
|
|
- {`{\n\ttheme: "light" | "dark",\n\tdirection: "TOP" | "RIGHT" | "DOWN" | "LEFT"\n}`}
|
|
|
|
- </SyntaxHighlighter>
|
|
|
|
- </p>
|
|
|
|
|
|
+ See the Pen <a href="https://codepen.io/AykutSarac/pen/KKBpWVR">Untitled</a> by Aykut
|
|
|
|
+ Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
+ <a href="https://codepen.io">CodePen</a>.
|
|
|
|
+ </StyledFrame>
|
|
|
|
+ </StyledContentBody>
|
|
|
|
+ </StyledContent>
|
|
|
|
+ <StyledContent>
|
|
|
|
+ <h2># Embed Saved JSON</h2>
|
|
|
|
+ <StyledContentBody>
|
|
|
|
+ <StyledDescription>
|
|
|
|
+ Just like fetching from URL above, you can embed saved public json by adding the json
|
|
|
|
+ id to "json" query{" "}
|
|
|
|
+ <StyledHighlight>?json=639b65c5a82efc29a24b2de2</StyledHighlight>
|
|
|
|
+ </StyledDescription>
|
|
|
|
+ <StyledFrame
|
|
|
|
+ scrolling="no"
|
|
|
|
+ title="Untitled"
|
|
|
|
+ src="https://codepen.io/AykutSarac/embed/vYaORgM?default-tab=html%2Cresult"
|
|
|
|
+ loading="lazy"
|
|
|
|
+ >
|
|
|
|
+ See the Pen <a href="https://codepen.io/AykutSarac/pen/vYaORgM">Untitled</a> by Aykut
|
|
|
|
+ Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
+ <a href="https://codepen.io">CodePen</a>.
|
|
|
|
+ </StyledFrame>
|
|
|
|
+ </StyledContentBody>
|
|
|
|
+ </StyledContent>
|
|
|
|
+ <StyledContent>
|
|
|
|
+ <h2># Communicating with API</h2>
|
|
|
|
+ <h3>◼︎ Post Message to Embed</h3>
|
|
|
|
+ <StyledContentBody>
|
|
|
|
+ <StyledDescription>
|
|
|
|
+ Communicating with the embed is possible with{" "}
|
|
|
|
+ <StyledHighlight
|
|
|
|
+ as="a"
|
|
|
|
+ href="https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage"
|
|
|
|
+ link
|
|
|
|
+ >
|
|
|
|
+ MessagePort
|
|
|
|
+ </StyledHighlight>
|
|
|
|
+ , you should pass an object consist of "json" and "options" key
|
|
|
|
+ where json is a string and options is an object that may contain the following:
|
|
|
|
+ <SyntaxHighlighter language="markdown" style={materialDark} showLineNumbers={true}>
|
|
|
|
+ {`{\n\ttheme: "light" | "dark",\n\tdirection: "TOP" | "RIGHT" | "DOWN" | "LEFT"\n}`}
|
|
|
|
+ </SyntaxHighlighter>
|
|
|
|
+ </StyledDescription>
|
|
|
|
|
|
- <StyledFrame
|
|
|
|
- scrolling="no"
|
|
|
|
- title="Untitled"
|
|
|
|
- src="https://codepen.io/AykutSarac/embed/rNrVyWP?default-tab=html%2Cresult"
|
|
|
|
- loading="lazy"
|
|
|
|
- >
|
|
|
|
- See the Pen <a href="https://codepen.io/AykutSarac/pen/rNrVyWP">Untitled</a> by Aykut
|
|
|
|
- Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
- <a href="https://codepen.io">CodePen</a>.
|
|
|
|
- </StyledFrame>
|
|
|
|
- </StyledContentBody>
|
|
|
|
- </StyledContent>
|
|
|
|
- <StyledContent>
|
|
|
|
- <h3>◼︎ On Page Load</h3>
|
|
|
|
- <StyledContentBody>
|
|
|
|
- <p>
|
|
|
|
- <StyledHighlight as="div" alert>
|
|
|
|
- ⚠️ <b>Important!</b> - iframe should be defined before the script tag
|
|
|
|
- </StyledHighlight>
|
|
|
|
- <StyledHighlight as="div" alert>
|
|
|
|
- ⚠️ <b>Note</b> - postMessage should be delayed using setTimeout
|
|
|
|
- </StyledHighlight>
|
|
|
|
- To display JSON on load event, you should post json into iframe using it's onload
|
|
|
|
- event like in the example. Make sure to use{" "}
|
|
|
|
- <StyledHighlight>setTimeout</StyledHighlight> when loading data and set a time around
|
|
|
|
- 500ms otherwise it won't work.
|
|
|
|
- </p>
|
|
|
|
- <StyledFrame
|
|
|
|
- scrolling="no"
|
|
|
|
- title="Untitled"
|
|
|
|
- src="https://codepen.io/AykutSarac/embed/QWBbpqx?default-tab=html%2Cresult"
|
|
|
|
- loading="lazy"
|
|
|
|
- >
|
|
|
|
- See the Pen <a href="https://codepen.io/AykutSarac/pen/QWBbpqx">Untitled</a> by Aykut
|
|
|
|
- Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
- <a href="https://codepen.io">CodePen</a>.
|
|
|
|
- </StyledFrame>
|
|
|
|
- </StyledContentBody>
|
|
|
|
- </StyledContent>
|
|
|
|
- </StyledPage>
|
|
|
|
|
|
+ <StyledFrame
|
|
|
|
+ scrolling="no"
|
|
|
|
+ title="Untitled"
|
|
|
|
+ src="https://codepen.io/AykutSarac/embed/rNrVyWP?default-tab=html%2Cresult"
|
|
|
|
+ loading="lazy"
|
|
|
|
+ >
|
|
|
|
+ See the Pen <a href="https://codepen.io/AykutSarac/pen/rNrVyWP">Untitled</a> by Aykut
|
|
|
|
+ Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
+ <a href="https://codepen.io">CodePen</a>.
|
|
|
|
+ </StyledFrame>
|
|
|
|
+ </StyledContentBody>
|
|
|
|
+ </StyledContent>
|
|
|
|
+ <StyledContent>
|
|
|
|
+ <h3>◼︎ On Page Load</h3>
|
|
|
|
+ <StyledContentBody>
|
|
|
|
+ <StyledDescription>
|
|
|
|
+ <StyledHighlight as="div" alert>
|
|
|
|
+ ⚠️ <b>Important!</b> - iframe should be defined before the script tag
|
|
|
|
+ </StyledHighlight>
|
|
|
|
+ <StyledHighlight as="div" alert>
|
|
|
|
+ ⚠️ <b>Note</b> - postMessage should be delayed using setTimeout
|
|
|
|
+ </StyledHighlight>
|
|
|
|
+ To display JSON on load event, you should post json into iframe using it's onload
|
|
|
|
+ event like in the example. Make sure to use{" "}
|
|
|
|
+ <StyledHighlight>setTimeout</StyledHighlight> when loading data and set a time around
|
|
|
|
+ 500ms otherwise it won't work.
|
|
|
|
+ </StyledDescription>
|
|
|
|
+ <StyledFrame
|
|
|
|
+ scrolling="no"
|
|
|
|
+ title="Untitled"
|
|
|
|
+ src="https://codepen.io/AykutSarac/embed/QWBbpqx?default-tab=html%2Cresult"
|
|
|
|
+ loading="lazy"
|
|
|
|
+ >
|
|
|
|
+ See the Pen <a href="https://codepen.io/AykutSarac/pen/QWBbpqx">Untitled</a> by Aykut
|
|
|
|
+ Saraç (<a href="https://codepen.io/AykutSarac">@AykutSarac</a>) on{" "}
|
|
|
|
+ <a href="https://codepen.io">CodePen</a>.
|
|
|
|
+ </StyledFrame>
|
|
|
|
+ </StyledContentBody>
|
|
|
|
+ </StyledContent>
|
|
|
|
+ </StyledPage>
|
|
|
|
+ <Footer />
|
|
|
|
+ </>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|