diff --git a/package.json b/package.json index 0664d8c..5e1ce8d 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "publishConfig": { "access": "public" }, + "types": "src/main.d.ts", "main": "src/main.js", "exports": { ".": "./src/main.js", diff --git a/src/main.d.ts b/src/main.d.ts new file mode 100644 index 0000000..34e6b29 --- /dev/null +++ b/src/main.d.ts @@ -0,0 +1,14 @@ +declare module "@theme/Sandbox" { + interface Props { + codeMirror?: boolean; + height: string; + hideDevTools?: boolean; + id: string; + inline?: boolean; + previewWindow?: string; + } + + export default function Sandbox(props: Props): JSX.Element; +} + +export function buildUrl(id: string): string; diff --git a/src/sandbox.js b/src/sandbox.js new file mode 100644 index 0000000..fcf67d2 --- /dev/null +++ b/src/sandbox.js @@ -0,0 +1,10 @@ +module.exports = { + buildUrl, +}; + +function buildUrl(id) { + const url = new URL("https://codesandbox.io/"); + url.pathname = `/s/${id}`; + + return url.toString(); +}