Example repo for 11ty/eleventy#2248.
This gist was created by @pspeter3!
Example repo for 11ty/eleventy#2248.
This gist was created by @pspeter3!
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") { |
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); |
// 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); | |
}; |
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(); |
module.exports = function(eleventyConfig) { | |
eleventyConfig.setBrowserSyncConfig({ | |
snippetOptions: { | |
rule: { | |
fn: function(snippet, match) { | |
return match; | |
} | |
} | |
} | |
}); |
<!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> | |
/* | |
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 |
// .eleventy.js | |
let Nunjucks = require("nunjucks"); | |
module.exports = function(eleventyConfig) { | |
let env = Nunjucks.configure(".", { | |
tags: { | |
blockStart: '<?php', | |
blockEnd: '?>', | |
} | |
}); |
--------------------------------------------------------- | |
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 |