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 / .js
Created August 29, 2019 16:43
Using Eleventy Programmatically
const Eleventy = require("@11ty/eleventy");
(async function() {
let inst = new Eleventy();
await inst.init();
await inst.write();
})();
@zachleat
zachleat / gist:2008932
Created March 9, 2012 21:56
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@zachleat
zachleat / jquery.postmessage.js
Created April 10, 2013 14:21
postMessage polyfill for IE < 8 that uses window.name and queues messages so they aren't lost while polling. Requires a JSON.parse polyfill (like JSON.js).
/*!
* jQuery postMessage - v1.0 - 8/26/2011
*
* Copyright (c) 2011 "zachleat" Zach Leatherman
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://jquery.org/license
*/
/* Forked from http://benalman.com/projects/jquery-postmessage-plugin/
@zachleat
zachleat / critical-foft-data-uri.html
Last active October 21, 2021 07:25
Compare Critical FOFT with Data URI against Critical FOFT
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Critical FOFT with Data URI</title>
<style>
@font-face {
font-family: LatoSubset;
src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAABVwAA0AAAAAG+QAARqgAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABMAAAABYAAAAWABEANkdQT1MAAAFIAAACkQAAA9wvekOPT1MvMgAAA9wAAABcAAAAYNjUqmVjbWFwAAAEOAAAADgAAABEAIcBBGdhc3AAAARwAAAACAAAAAgAAAAQZ2x5ZgAABHgAAA8EAAAUUN1x8mZoZWFkAAATfAAAADYAAAA2DA2UbWhoZWEAABO0AAAAHgAAACQPOga/aG10eAAAE9QAAADIAAAA2PXwFPVsb2NhAAAUnAAAAG4AAABuhQSA721heHAAABUMAAAAGgAAACAAOgBgbmFtZQAAFSgAAAA0AAAANAI2Codwb3N0AAAVXAAAABMAAAAg/3QAegABAAAADAAAAAAAAAACAAEAAQA1AAEAAHicTZO/SxthGMe/d4k2NFbSFE2Maaq2tJ4/qtE4dwnBoUgoHUq5pWBBaCv0h4OCS2MLGUuXIhlKhwxFMnVwcAvB4SiSQSRkOEK9xan/wdvPRYQSnrzv3fu8n8/7vO97siRd1z0tyS6WHj/V8OsXHzY1rCjvZYzCcevVy3ebioW9fkRl99sYUepn5vTZWtOhdW7v6MJas+aIDeujdW5d2GV7x/4VSUaKkSf8ipFN4rK/EdnjaQ9KDuKArimuId1QQjeV1C2NaFQppTWmjMaV1W1N6K7ua1qOZjSreeW1
@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;
}
}
}
});