Skip to content

binyamin/eleventy-plugin-preact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A personal Eleventy plugin for rendering JSX/TSX as HTML, with Preact.

Usage

Add the plugin to your eleventy config, like so:

const eleventyPreact = require("@binyamin/eleventy-preact");

module.exports = function(eleventyConfig) {
    eleventyConfig.addPlugin(eleventyPreact, {
        /* options */
    });
}

Customization

  • doctype (boolean) - Determines whether to add a doctype (<!DOCTYPE HTML>) before the rendered HTML. The doctype is never applied to JSX rendered via the shortcode.
  • shortcode (string or false) - This will register a shortcode with the given name, which renders a JSX file in-place. Setting it to false disables the shortcode. The shortcode takes two parameters. The first is a file path, relative to the includes directory. The second is an object, passed as props.

These are the default options:

{
    doctype: true,
    shortcode: "render_jsx"
}

Contributing

All input is welcome; feel free to open an issue. Please remember to be a mensch. If you want to program, you can browse the issue list.

Legal

All source-code is provided under the terms of the MIT license. Copyright 2022 Binyamin Aron Green.

About

Use Preact components within eleventy templates

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published