import-illustrations.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env node
  2. 'use strict'
  3. const fs = require('fs'),
  4. path = require('path'),
  5. glob = require('glob');
  6. const illustrations = glob
  7. .sync(path.join(__dirname, `../src/static/illustrations/light/*.png`))
  8. .map((file) => {
  9. return path.basename(file, '.png')
  10. })
  11. fs.writeFileSync(
  12. path.join(__dirname, `../src/pages/_data/illustrations.json`),
  13. JSON.stringify(illustrations)
  14. )
  15. // let i = {}
  16. // const dirs = ['light', 'dark', 'autodark']
  17. // const ilustrations = ['not-found', 'computer-fix', 'boy-with-key', 'boy-girl']
  18. // for(const dir of dirs) {
  19. // i[dir] = {}
  20. // for(const ilustration of ilustrations) {
  21. // let svg = fs.readFileSync(path.join(__dirname, `../src/pages/_free-illustrations/${dir}/${ilustration}.svg`), 'utf8')
  22. // svg = svg
  23. // .replace(/\n+/g, ' ')
  24. // .replace(/>\s+</g, '><')
  25. // .replace(/\s+/g, ' ')
  26. // .replace(/^[\n\s-]+/, '')
  27. // i[dir][ilustration] = svg
  28. // }
  29. // }
  30. // fs.writeFileSync(
  31. // path.join(__dirname, `../src/pages/_data/free-illustrations.json`),
  32. // JSON.stringify(i)
  33. // )