0.1.0 • Published 3 years ago

@themaxdavitt/hastscript-components v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@themaxdavitt/hastscript-components

Wrap hastscript to allow function pseudo-components

Install

npm install --save hastscript @themaxdavitt/hastscript-components

Usage

Pretend this is JSX, not the underlying transpiled calls.

import { jsx } from '@themaxdavitt/hastscript-components';

// Async functions are also supported
function Hello({ children, greeting }) {
	return jsx('p', { children: [greeting, ' ', ...children, '!'] });
}

// <Hello greeting="Hello">Max</Hello> => <p>Hello Max!</p>
console.log(await jsx(Hello, { children: ['Max'], greeting: 'Hello' }));

// <p>Hello world!</p>
console.log(await jsx('p', { children: ['Hello world!'] }));

License

MIT License, see LICENSE.