diff --git a/.eleventy.js b/.eleventy.js index 2db345c..6a18ad5 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -5,8 +5,16 @@ const { EleventyPluginCodeDemo } = require('./src'); */ module.exports = (eleventyConfig) => { eleventyConfig.addPlugin(EleventyPluginCodeDemo, { - renderHead: ({ css }) => ``, - renderBody: ({ html, js }) => `${html}`, + renderDocument: ({ html, css, js }) => ` + +
+ + + + ${html} + + + `, iframeAttributes: { height: '100', }, diff --git a/README.md b/README.md index 713e315..8ebc3ff 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,17 @@ const { EleventyPluginCodeDemo } = require('eleventy-plugin-code-demo'); eleventyConfig.addPlugin(EleventyPluginCodeDemo, { // Use any shortcode name you want name: 'shortcodeName', - // Render whatever content you want to go in the - renderHead: ({ css }) => ``, - // Render whatever content you want to go in the - renderBody: ({ html, js }) => `${html}`, + // Render whatever document structure you want (other than doctype); the HTML, CSS, and JS parsed from the shortcode's body are supplied to this function as an argument, so you can position them wherever you want, or add class names or data-attributes to html/body + renderDocument: ({ html, css, js }) => ` + + + + + + ${html} + + + `, // key-value pairs for HTML attributes; these are applied to all code previews iframeAttributes: { height: '300', @@ -37,10 +44,9 @@ See [example usage](#example-usage) for how to use the shortcode. |Name|Type|Description| |----|----|-----------| -|`name`|`string`|The name to use for the shortcode. Defaults to `'codeDemo'` if not specified.| -|`renderHead`|`(args: { css: string; js: string }) => string`|A render function to return custom markup for the iframe ``'s children.| -|`renderBody`|`(args: { html: string; js: string }) => string`|A render function to return custom markup for the iframe ``'s children.| -|`iframeAttributes`|`Record