jsx-slack
Version:
Build JSON object for Slack Block Kit surfaces from JSX
2 lines (1 loc) • 539 B
JavaScript
import i from"../../vendor/htm/mini/index.mjs";import{decodeEntity as c}from"./escape.mjs";const s=t=>t.replace(/&/g,"&").replace(/(?![\t\n\r ])\s/g,e=>`&#${e.codePointAt(0)};`),d=i.bind((t,e,...p)=>{const r={tagName:t,type:"element",properties:{},children:[]};for(const o of e?Object.keys(e):[])r.properties[o]=c(e[o]);for(const o of p){const n=c(o);r.children.push(typeof n=="string"?{value:s(n),type:"text"}:n)}return r});function a(t){const{children:e}=d([`<body>${t}</body>`]);return{type:"root",children:e}}export{a as default};