Just another eleventy codepen plugin.
npm install @aloskutov/eleventy-plugin-codepen
const codepen = require("@aloskutov/eleventy-plugin-codepen");
module.exports = (eleventyConfig) => {
eleventyConfig.addPlugin(codepen);
};
To add Codepen's javascript code to all pages, paste in the template:
...
{% codepen_js %}
</body>
</html>
To optionally add Codepen's javascript code to all pages, paste in the template:
...
{% if codepen %}{% codepen_js %}{% endif %}
</body>
</html>
If you use optional, then on the content page, insert in the header codepen: true
:
---
codepen: true
...
---
...
{% codepen "pen-url", '{"option":"value"}' %}
Option | Type | Default | |
---|---|---|---|
height | integer | 450 | Iframe height in pixels |
tab | string | result | Active tab. Possible values: result , html , css , js . |
theme | string | dark | Theme, dark , light or theme id |
class | string | none | CSS class (classes) to add to the iframe |
For example, custom style for resizable block:
.codepen-resizable {
overflow: hidden;
resize: both;
background: white;
padding-bottom: 10px;
}
.codepen-resizable iframe {
height: 100% !important;
}
{% codepen "some-pen-url-or-id", '{"style":"codepen-resizable"}' %}
Liquid & Nunjucks template:
{% codepen "some-pen-url-or-id", '{"height":500,"style":"codepen-resizable"}' %}
or option string
{% codepen "some-pen-url-or-id", "height:500,style:codepen-resizable" %}
Nunjucks template:
{% codepen "some-pen-url-or-id", {height:500, style:"codepen-resizable"} %}