Skip to content

Commit 3a92fac

Browse files
Import from another project with light cleanup
1 parent a0c74a9 commit 3a92fac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2831
-0
lines changed

.eleventy.js

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
const { DateTime } = require("luxon");
2+
const CleanCSS = require("clean-css");
3+
const UglifyJS = require("uglify-es");
4+
const sanitizeHTML = require('sanitize-html')
5+
const htmlmin = require("html-minifier");
6+
const widont = require("widont");
7+
const md = require("markdown-it")({
8+
html: true,
9+
linkify: true,
10+
typographer: true,
11+
});
12+
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
13+
const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language");
14+
15+
module.exports = function(eleventyConfig) {
16+
17+
// Date formatting (human readable)
18+
eleventyConfig.addFilter("readableDate", date => {
19+
return DateTime.fromJSDate(date).toFormat("dd LLL yyyy");
20+
});
21+
22+
// Date formatting (machine readable)
23+
eleventyConfig.addFilter("machineDate", date => {
24+
return DateTime.fromJSDate(date).toISO();
25+
});
26+
27+
// Markdownify
28+
eleventyConfig.addFilter("markdownify", text => {
29+
return md.renderInline( text );
30+
});
31+
32+
// unSluggify
33+
eleventyConfig.addFilter("unslug", text => {
34+
text = text.charAt(0).toUpperCase() + text.slice(1);
35+
return text.replace(/-/g, ' ');
36+
});
37+
38+
// Name List
39+
eleventyConfig.addShortcode("NameList", names => {
40+
let strings = [],
41+
string = "",
42+
count = names.length;
43+
while ( count-- )
44+
{
45+
let url = names[count].url || `https://twitter.com/${names[count].twitter}/`;
46+
strings.unshift( `<a href="${url}">${names[count].name}</a>` );
47+
}
48+
count = strings.length;
49+
if ( count > 2 )
50+
{
51+
strings[count-1] = "and " + strings[count-1];
52+
string = strings.join(", ");
53+
}
54+
else if ( count == 2 )
55+
{
56+
string = `${strings[0]} and ${strings[1]}`;
57+
}
58+
else
59+
{
60+
string = strings[0];
61+
}
62+
return `${string}`;
63+
});
64+
65+
// Fix proper nouns
66+
eleventyConfig.addFilter("fixNames", text => {
67+
let test = text.toLowerCase(),
68+
acronyms = [ "html", "css", "svg" ],
69+
camel_case = [ "JavaScript" ],
70+
i, proper_name;
71+
72+
if ( acronyms.indexOf( test ) > -1 )
73+
{
74+
return text.toUpperCase();
75+
}
76+
else
77+
{
78+
for ( i in camel_case )
79+
{
80+
proper_name = camel_case[i];
81+
if ( proper_name.toLowerCase() == test )
82+
{
83+
return proper_name;
84+
}
85+
}
86+
}
87+
return text;
88+
});
89+
90+
// Widont
91+
eleventyConfig.addFilter("widont", function(text) {
92+
return `${widont( text )}`;
93+
});
94+
95+
96+
// Minify CSS
97+
eleventyConfig.addFilter("cssmin", function(code) {
98+
return new CleanCSS({}).minify(code).styles;
99+
});
100+
101+
// Minify JS
102+
eleventyConfig.addFilter("jsmin", function(code) {
103+
let minified = UglifyJS.minify(code);
104+
if (minified.error) {
105+
console.log("UglifyJS error: ", minified.error);
106+
return code;
107+
}
108+
return minified.code;
109+
});
110+
111+
// Minify HTML output
112+
eleventyConfig.addTransform("htmlmin", function(content, outputPath) {
113+
if (outputPath.indexOf(".html") > -1) {
114+
let minified = htmlmin.minify(content, {
115+
useShortDoctype: true,
116+
removeComments: true,
117+
collapseWhitespace: true,
118+
collapseBooleanAttributes: true
119+
});
120+
minified = minified.replace('\u00a0', '<b class="shy">\u00a0</b>');
121+
return minified;
122+
}
123+
return content;
124+
});
125+
126+
// Minify JS output
127+
eleventyConfig.addTransform("jsmin", function(content, outputPath) {
128+
if (outputPath.indexOf(".js") > -1) {
129+
let minified = UglifyJS.minify(content);
130+
return minified;
131+
}
132+
return content;
133+
});
134+
135+
// limit filter
136+
eleventyConfig.addNunjucksFilter("limit", function(array, limit) {
137+
return array.slice(0, limit);
138+
});
139+
140+
eleventyConfig.addCollection("devs", collection => {
141+
// get unsorted items
142+
return collection.getAll().filter( item => {
143+
return item.inputPath.indexOf("devs/") > -1;
144+
});
145+
});
146+
eleventyConfig.addFilter("extractID", url => {
147+
url = url.split("/");
148+
return url[2];
149+
});
150+
151+
eleventyConfig.addCollection("tags", function(collection) {
152+
// get unsorted items
153+
var tags = [];
154+
collection.getAll()
155+
.map( item => {
156+
if ( item.inputPath.indexOf("wants/") > -1 )
157+
{
158+
item.data.tags.map( tag => {
159+
if ( tags.indexOf( tag ) < 0 )
160+
{
161+
tags.push( tag );
162+
}
163+
});
164+
}
165+
});
166+
return tags.sort();
167+
});
168+
169+
eleventyConfig.addFilter("toString", function(collection, separator, props) {
170+
var ret = [],
171+
i = collection.length;
172+
while ( i-- )
173+
{
174+
let str = [],
175+
j = props.length;
176+
while ( j-- )
177+
{
178+
let text = collection[i].data[props[j]];
179+
if ( props[j].indexOf("date") > -1 )
180+
{
181+
text = new Date( text );
182+
text = DateTime.fromJSDate(text).toFormat("dd LLL yyyy");
183+
}
184+
str.unshift( text );
185+
}
186+
ret.unshift( str.join( separator ) );
187+
}
188+
return ret;
189+
});
190+
191+
eleventyConfig.addFilter("getDirectory", function(url) {
192+
url = url.split('/');
193+
return url[1];
194+
});
195+
196+
// Don't process folders with static assets e.g. images
197+
eleventyConfig.addPassthroughCopy("sw.js");
198+
eleventyConfig.addPassthroughCopy("static/img");
199+
eleventyConfig.addPassthroughCopy("static/js");
200+
eleventyConfig.addPassthroughCopy("manifest.json");
201+
eleventyConfig.addPassthroughCopy("admin");
202+
// eleventyConfig.addPassthroughCopy("_includes/assets/");
203+
204+
/* Markdown Plugins */
205+
let markdownIt = require("markdown-it");
206+
let markdownItAnchor = require("markdown-it-anchor");
207+
let options = {
208+
html: true,
209+
breaks: true,
210+
linkify: true
211+
};
212+
let opts = {
213+
permalink: false
214+
};
215+
216+
eleventyConfig.setLibrary("md", markdownIt(options)
217+
.use(markdownItAnchor, opts)
218+
);
219+
220+
eleventyConfig.addPlugin(syntaxHighlight);
221+
222+
//eleventyConfig.addPlugin(inclusiveLangPlugin);
223+
224+
return {
225+
templateFormats: ["md", "njk", "html", "liquid"],
226+
227+
// If your site lives in a different subdirectory, change this.
228+
// Leading or trailing slashes are all normalized away, so don’t worry about it.
229+
// If you don’t have a subdirectory, use "" or "/" (they do the same thing)
230+
// This is only used for URLs (it does not affect your file structure)
231+
pathPrefix: "/",
232+
233+
markdownTemplateEngine: "liquid",
234+
htmlTemplateEngine: "njk",
235+
dataTemplateEngine: "njk",
236+
passthroughFileCopy: true,
237+
dir: {
238+
input: ".",
239+
includes: "_includes",
240+
data: "_data",
241+
output: "_site"
242+
}
243+
};
244+
};

.eleventyignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

404.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: 404
3+
layout: layouts/page.njk
4+
permalink: /404.html
5+
---
6+
Uh oh, the resource you requested isn't here. Sorry.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Aaron Gustafson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

_data/metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"title": "Devs of Colour",
3+
"url": "https://devsofcolour.org",
4+
"domain": "devsofcolour.org",
5+
"author": {
6+
"name": "Tatiana Mac",
7+
"email": "??",
8+
"github": "https://github.com/tatianamac"
9+
}
10+
}

0 commit comments

Comments
 (0)