How to use the codesandbox/lib/api/define.getParameters function in codesandbox

To help you get started, we’ve selected a few codesandbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rei / rei-cedar-docs / utils / buildSandbox.js View on Github external
'package.json': {
        content: {
          "name": data.name,
          "description": "TODO: put description of each code example here",
          "dependencies": {
            "@rei/cdr-assets": "^0.3.0",
            "vue": "2.5.16",
            ...dependencies
          }
        },
      },
    },
  };

  console.log(data, parameters);
  return `https://codesandbox.io/api/v1/sandboxes/define?parameters=${getParameters(parameters)}`;
}
github logaretm / vee-validate / docs / .vuepress / codesandbox.js View on Github external
export function makeExample (source) {
  return getParameters({
    files: {
      "src/Demo.vue": {
        content: source
      },
      "src/App.vue": {
        content: `<template>
  
</template>

github featurist / browser-monkey / docs / update-readme-example-links.js View on Github external
function generateExampleSandboxLink (exampleTemplateName, exampleCode) {
  const templatePath = `${process.cwd()}/docs/codesandbox/${exampleTemplateName}`
  const parameters = getParameters({
    files: {
      'package.json': {
        content: fs.readFileSync(`${templatePath}/package.json`, { encoding: 'utf-8' })
      },
      'src/app.spec.js': {
        content: exampleCode
      },
      'src/app.js': {
        content: fs.readFileSync(`${templatePath}/src/app.js`, { encoding: 'utf-8' })
      },
      'src/index.js': {
        content: fs.readFileSync(`${templatePath}/src/index.js`, { encoding: 'utf-8' })
      },
      'index.html': {
        content: fs.readFileSync(`${templatePath}/index.html`, { encoding: 'utf-8' })
      }
github vuejs / vue-router / docs / .vuepress / example-preview / utils.js View on Github external
vue: 'latest',
            'vue-router': 'latest'
          }
        }
      },
      ...files.reduce(
        (fileMap, file) => ({
          ...fileMap,
          ...file
        }),
        {}
      )
    }
  }

  return getParameters(data)
}
github mlaursen / react-md / packages / documentation / components / Demos / SandboxDefineForm.tsx View on Github external
(async function load(): Promise {
      const files = await getSandbox();
      if (!cancelled) {
        setParameters(getParameters({ files }));
      }
    })();
github djyde / markbox / src / transformers.ts View on Github external
const js = (code) => {
  const parameters = getParameters({
    files: {
      "index.js": {
        content: code,
        isBinary: false
      },
      'index.html': {
        content: templates.indexHtml,
        isBinary: false,
      },
      "package.json": {
        isBinary: false,
        content: JSON.stringify({ dependencies: {
        }})
      }
    }
  });
github SAP / fundamental-vue / src / docs / components / d-playground-button / d-playground-button.vue View on Github external
parameters() {
      return getParameters(this.rawParameters)
    },
    rawParameters() {
github mlaursen / react-md / packages / documentation / src / components / Demos / SandboxDefineForm.tsx View on Github external
(async function load(): Promise {
      const files = await getSandbox();
      if (!cancelled) {
        setParameters(getParameters({ files }));
      }
    })();
github featurist / codesandbox-example-links / index.js View on Github external
result.splice(-1)
      }

      result.push('```')
    }

    const [isSanbdboxMatch, sandboxLink] = line.match(/\[codesandbox\]\((.*)\)/) || []

    if (isSanbdboxMatch) {
      const sandboxProjectPath = path.join(
        process.cwd(),
        sandboxLink
      )
      const files = getProjectFiles(sandboxProjectPath)
      debug('Generating link for files', files)
      const parameters = getParameters({files})

      const url = `https://codesandbox.io/api/v1/sandboxes/define?${iframe ? 'embed=1&amp;' : ''}parameters=${parameters}`
      const link = iframe
        ? ``
        : `<a rel="noopener noreferrer" href="${url}">Run this example</a>`

      result.push(link)
    }

    if (!isSanbdboxMatch &amp;&amp; !isSnippetMatch) {
      result.push(line)
    }

    return result
  }, [])

codesandbox

The CLI used for communicating with CodeSandbox

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Popular codesandbox functions