boxwood 0.71.2 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +28 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -431,6 +431,34 @@ const nodes = [
431
431
  return result
432
432
  }, {})
433
433
 
434
+ function extension(path) {
435
+ const parts = path.split(".")
436
+ return parts[parts.length - 1].toLowerCase()
437
+ }
438
+
439
+ function media(path) {
440
+ const type = extension(path)
441
+ return `image/${type === "jpg" ? "jpeg" : type}`
442
+ }
443
+
444
+ function base64({ content, path }) {
445
+ return `data:${media(path)};base64,${content}`
446
+ }
447
+
448
+ nodes.img.load = function () {
449
+ const path = join(...arguments)
450
+ const content = readFileSync(path, "base64")
451
+ return (options) => {
452
+ return nodes.img({ src: base64({ content, path }), ...options })
453
+ }
454
+ }
455
+
456
+ nodes.svg.load = function () {
457
+ const path = join(...arguments)
458
+ const content = readFileSync(path, "utf8")
459
+ return raw(content)
460
+ }
461
+
434
462
  function classes() {
435
463
  const array = []
436
464
  for (let i = 0, ilen = arguments.length; i < ilen; i += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.71.2",
3
+ "version": "0.72.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {