Skip to content

Instantly share code, notes, and snippets.

View danfascia's full-sized avatar
🎲
Dabbling

danfascia

🎲
Dabbling
View GitHub Profile
@danfascia
danfascia / box-shadow-hover.css
Created July 16, 2018 10:03
Nice box shadow with :hover
.box-shadow, .hover-box-shadow:hover { box-shadow: 0 0.5em 2em 0 rgba(100,100,100,.33); }
@danfascia
danfascia / svg-bottom-align-in-container.html
Created December 22, 2018 19:21
Prevents a gap at the bottom of a container containing an SVG intended to be bottom placed (i.e. as a bottom border shape)
<svg style="display: block; position: absolute; width: 100%; bottom: 0; top: 100%">
<line id="HorizontalLine1118" x1="0" x2="100%" y1="0" y2="0"></line>
</svg>
@danfascia
danfascia / svg-pie-charts.html
Created December 23, 2018 18:55
Neat responsive SVG pie charts (no javascript)
<!--
Neat way to render responsive pie charts in HTML with SVGs and CSS from https://www.smashingmagazine.com/2015/07/designing-simple-pie-charts-with-css/
-->
<style>
svg.piechart {
transform: rotate(-90deg);
background: #B0233B;
border-radius: 50%;
}
@danfascia
danfascia / index.html
Last active January 10, 2019 22:23 — forked from jonathan-soifer/index.html
Very basic boilerplate Index.html for Hugo Static Website Generator
<!DOCTYPE html>
<html lang="en" />
<head>
<!-- Set character encoding for the document -->
<meta charset="UTF-8" />
<!-- Instruct Internet Explorer to use its latest rendering engine -->
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<!-- Viewport for responsive web design -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
@danfascia
danfascia / 11ty_contains.js
Last active February 9, 2023 22:19
11ty filter to filter a collection (array) by key:value pair - used to filter on custom taxonomies other than tags (source: https://paulrobertlloyd.com/)
/**
* Select objects in array whose key includes a value
*
* @param {Array} arr Array to test
* @param {String} key Key to inspect
* @param {String} value Value key needs to include
* @return {String} Filtered array
*
*/
module.exports = function (arr, key, value) {
@danfascia
danfascia / 11ty_is.js
Created February 15, 2019 10:48
11ty filter to filter items in a collection (array) whose key === value. (source: https://paulrobertlloyd.com/)
/**
* Select objects in array whose key matches a value
*
* @param {Array} arr Array to test
* @param {String} key Key to inspect
* @param {String} value Value key needs to match
* @return {String} Filtered array
*
*/
module.exports = function (arr, key, value) {
@danfascia
danfascia / 11ty_permalink.js
Created February 15, 2019 10:51
Removes index.html from 11ty URL strings to create prettier permalinks. Usage {{url | permalink}} (source: https://paulrobertlloyd.com/)
@danfascia
danfascia / 11ty_date.js
Created February 15, 2019 12:21
11ty Date formatting filter using Luxon. Usage: {{ date_field | date('dd LLLL yyyy') }}
const { DateTime } = require("luxon");
// date filter formatting using Luxon. Usage: {{ date_field | date('dd LLLL yyyy') }}
eleventyConfig.addFilter("date", (it, format = "LLLL dd, yyyy") => {
return DateTime.fromJSDate(it, { zone: "utc" }).toFormat(format);
});
@danfascia
danfascia / 11ty_is-not.js
Created February 16, 2019 21:17
11ty filter to remove items from a filtered array by key:value pair - i.e. {% collection_array... | is-not: 'url', page.url %} (source: https://paulrobertlloyd.com/)
/**
* Remove objects in array whose key matches a value
*
* @param {Array} arr Array to test
* @param {String} key Key to inspect
* @param {String} value Value key needs to match
* @return {String} Filtered array
*
*/
module.exports = function (arr, key, value) {
@danfascia
danfascia / 11ty_excerpts.js
Created February 17, 2019 20:14
11ty filter to split a string {{content}} into an excerpt (i.e. all stuff before <!--more-->) and the remainder (i.e. stuff after that tag...). Source: https://hawksworx.com
/**
* Split the content into excerpt and remainder
*
* @param {String} str
* @param {String [excerpt | remainder]} section
*
* If excerpt or nothing is passed as an argument, we return what was before the split marker.
* If remainder is passed as an argument, we return the rest of the post
*
*/