Tagged “jamstack”
Encapsulated Eleventy/Nunjucks components with macros (by Trys Mudford)
Trys shows us how to use the Nunjucks macro
to create encapsulated components. This works out less leaky and more predictable than an include
preceded by variables assigned with set
.
Trys’s solution allows us to render components like so:
{{ component('button', {
text: 'Press me'
}) }}
{# Output #}
<button type="button">Press me</button>
Update, 8th Aug 2021: when I tried implementing this I found that it results in errors when attempting to render components anywhere other than on the base template where Trys recommended including the import
line. The workaround—as Paul Salaets points out—is to include the import
at the top of every page-level template (index.njk
, archive.njk
etc) that uses the component macro.
Emergency Website Kit (Max Böck)
In cases of emergency, many organizations need a quick way to publish critical information. But existing (CMS) websites are often unable to handle sudden spikes in traffic.
Fantastic effort by Max Böck here, stepping up during the COVID-19 pandemic to provide this Eleventy template for organisations to use to publish critical information as lean, resilient, static HTML pages.
Let’s Learn Eleventy! (with Zach Leatherman) - Learn With Jason (YouTube)
A great tutorial video on Eleventy by Jason Lengstorf with guest Zach Leatherman, creator of Eleventy.
I already know Eleventy pretty well – in fact this site is built with Eleventy. But you always pick up lots of great tips by watching the people who really know their way around the software.
(via @jlengstorf)
See all tags.