Skip to content

Instantly share code, notes, and snippets.

View zachleat's full-sized avatar
🚨
GitHub Drop ICE

Zach Leatherman zachleat

🚨
GitHub Drop ICE
View GitHub Profile
@zachleat
zachleat / README.md
Last active October 16, 2023 23:59 — forked from pspeter3/.eleventyignore
Eleventy 11ty.js Extensions
@zachleat
zachleat / .eleventy.js
Created October 12, 2022 13:27
Add to Calendar Urls in Eleventy
const { google, outlook, office365, yahoo, ics } = require("calendar-link");
module.exports = function(eleventyConfig) {
// `event` structure documented on https://www.npmjs.com/package/calendar-link
eleventyConfig.addLiquidFilter("addToCalendar", (event, type) => {
if(type === "google") {
return google(event);
} else if(type === "office365") {
return office365(event);
} else if(type === "outlook") {
@zachleat
zachleat / eleventy.config.js
Last active August 25, 2022 13:37
JSMin filter with a cache
const { minify } = require('terser');
const jsMinCache = {};
module.exports = function (eleventyConfig) {
eleventyConfig.addNunjucksAsyncFilter('jsmin', async function (code, callback) {
try {
if(jsMinCache[code]) {
callback(null, jsMinCache[code]);
} else {
const minified = await minify(code);
@zachleat
zachleat / .eleventy.js
Created June 24, 2022 15:08
Add your own Handlebars partial directlyto Eleventy
// via https://www.11ty.dev/docs/languages/handlebars/#optional-set-your-own-library-instance
module.exports = function(eleventyConfig) {
let handlebars = require("handlebars");
// see https://handlebarsjs.com/guide/partials.html#basic-partials
handlebars.registerPartial("name", "Handlebars syntax");
eleventyConfig.setLibrary("hbs", handlebars);
};
@zachleat
zachleat / .eleventy.js
Last active July 9, 2021 14:10
Eleventy URL Linter to check for changed URLs when swapping from `slug` to `slugify` filters (via @pdehaan)
const assert = require("assert");
const inspect = require("util").inspect;
module.exports= (eleventyConfig) => {
// ever so slightly modified from @pdehaan’s original:
// https://github.com/11ty/eleventy/issues/278#issuecomment-873367464
const slugFn = eleventyConfig.getFilter("slug");
const slugifyFn = eleventyConfig.getFilter("slugify");
const slugErrors = new Set();
@zachleat
zachleat / .eleventy.js
Created June 8, 2021 20:21
Use browser-sync in Eleventy without browser-sync JavaScript (opt-out of automatic page refresh)
module.exports = function(eleventyConfig) {
eleventyConfig.setBrowserSyncConfig({
snippetOptions: {
rule: {
fn: function(snippet, match) {
return match;
}
}
}
});
@zachleat
zachleat / index.html
Created March 6, 2021 23:17
HTML Boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<title></title>
</head>
<body>
@zachleat
zachleat / queuecode.js
Last active March 7, 2021 02:21
Queue Code Starter Gist
/*
Queue Code
https://queuecode.zachleat.dev/
Usage:
- Press any key to reveal the next character of source code. Use delete to hide characters.
- Use the `url` query param to point to a different source code file.
e.g. https://queuecode.zachleat.dev/?url=https://gist.githubusercontent.com/zachleat/a7393810acf7890e6bef6a34eaa7b78c/raw/smoothscroll.css
@zachleat
zachleat / gist:dd68700493492517ae718c2f148debc2
Created September 11, 2020 23:03
Pretend PHP in Eleventy with Nunjucks
// .eleventy.js
let Nunjucks = require("nunjucks");
module.exports = function(eleventyConfig) {
let env = Nunjucks.configure(".", {
tags: {
blockStart: '<?php',
blockEnd: '?>',
}
});
@zachleat
zachleat / gist:f100f71a8ad2bad57d65511290717f1c
Created September 7, 2020 21:42
Eleventy Benchmark September 7, 2020 (Eleventy 1.0 Alpha Build)
---------------------------------------------------------
Eleventy Benchmark (Node v14.9.0, 1000 templates each)
---------------------------------------------------------
Eleventy 0.10.0
---------------------------------------------------------
liquid: ... 3 runs
* Median: 1.02 seconds
* Median per template: 1 ms
njk: ... 3 runs