0.1.0-alpha.b035843b • Published 7 years ago

barnes-preact v0.1.0-alpha.b035843b

Weekly downloads
6
License
-
Repository
-
Last release
7 years ago

Barnes-Preact

Render your files into strings with Preact components!

Prerequisites

You'll need to have some Preact components lying around - this can be either imported and passed directly as a layout property or as a string, to be required by the plugin.

Installation

yarn add barnes-preact

Usage

import Barnes from 'barnes';
import preact from 'barnes-preact';

// pass an optional (can be async) function; its result will be passed as the
// component's data prop
import query from './query';

(async () => {
  await new Barnes('/Users/Dev/Documents')
    .read('**/*.md')
    // assign layout property to each file
    .map(file => Object.assign(file, { layout }))
    // convert layout'd files to HTML
    .map(preact(query))
    // all layout'd files are now HTML!
    .write('public');
}());