threepipe
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

simple-code-preview.mjs 1.1KB

123456789101112131415161718
  1. import {setupCodePreview} from 'https://cdn.jsdelivr.net/gh/repalash/example-code-previewer/dist/index.js';
  2. const exampleScript = document.getElementById('example-script')
  3. const scripts = exampleScript && exampleScript.dataset.scripts ? exampleScript.dataset.scripts.split(';') : []
  4. if(exampleScript.textContent) scripts.push(exampleScript)
  5. const exampleStyle = document.querySelector('#example-style')
  6. const css = exampleStyle ? exampleStyle.textContent : ''
  7. setupCodePreview(
  8. document.getElementById('canvas-container') || document.querySelector('.code-preview-container'),
  9. scripts,
  10. scripts.map(s=>s.textContent ? 'js' : s.split('.').pop()), // title
  11. scripts.map(s=>(typeof s === 'string' && s.endsWith('.js')) ? s : 'https://github.com/repalash/threepipe/tree/master/examples/'+ window.location.pathname.split('/examples/').pop().replace('index.html', '')+(s.textContent ? 'index.html' : s)), // todo: github link
  12. (c)=>c.replaceAll(" from 'threepipe'", " from 'https://repalash.com/threepipe/dist/index.mjs'"), // todo: fix link
  13. {
  14. title: 'ThreePipe: ' + document.title,
  15. css,
  16. },
  17. );