You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HyperMDX is an MDX-like library to enhance markdown with Hyperapp.
Features
Custom components for HTML elements
Embed Hyperapp components inside a page
Async and sync modes
Remark plugins support
Install
pnpm i hypermdx
Example
import{App}from'@tinyhttp/app'import{h,text}from'hyperapp'import{renderToStream}from'hyperapp-render'import{hypermdx}from'hypermdx'constComponent=(children: string)=>h('h3',{style: {color: 'red'}},text(children))constmd=hypermdx({components: {h1: (n,p,c)=>h(n,{style: {color: 'blue'}, ...p},c)}})constcontent=md`# This is a custom heading defined in components- this is a list- yet another list${Component('custom component')} `newApp().get(async(_,res)=>renderToStream(content).pipe(res)).listen(3000)
Output:
<div><div><h1style="color:blue">This is a custom heading defined in components</h1><ul><li><p>this is a list</p></li><li><p>yet another list</p></li></ul></div><h3style="color:red">custom component</h3></div>
API
hypermdx(options)
Creates an function to render markdown and components.