This repository has been archived by the owner on Mar 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
92 lines (75 loc) · 1.76 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const CleanCSS = require( "clean-css" );
const markdownIt = require( "markdown-it" );
const rssPlugin = require( "@11ty/eleventy-plugin-rss" );
module.exports = config =>
{
config.addPassthroughCopy( "src/icons" );
config.addPassthroughCopy({ "src/static": "/" });
config.addPlugin( rssPlugin, {
posthtmlRenderOptions: {}
});
/* Filters & Shortcodes */
config.addFilter( "cssmin", code =>
{
return new CleanCSS({})
.minify( code )
.styles;
});
config.addShortcode( "date", date =>
{
return date.toLocaleDateString( [], {
day: "2-digit",
month: "short",
year: "numeric",
});
});
config.addFilter( "dateFromString", string =>
{
return new Date( string );
});
config.addFilter( "slice", (array, start, end) =>
{
return array.slice( start, end );
});
config.addFilter( "sortPages", pages =>
{
return pages.sort( (pageA, pageB) =>
{
let sortPageA = pageA.data.sort || 0;
let sortPageB = pageB.data.sort || 0;
return sortPageA - sortPageB;
});
});
config.addFilter( "sortPosts", (posts, property="date", order="desc") =>
{
return posts.sort( (postA, postB) =>
{
let sortPostA = postA[property];
let sortPostB = postB[property];
if( order === "desc" )
{
return sortPostB - sortPostA;
}
return sortPostA - sortPostB;
});
});
/* Markdown configuration */
let markdownOptions = {
html: true,
breaks: false,
typographer: true,
};
let markdownLibrary = markdownIt( markdownOptions )
.disable( "code" );
markdownLibrary.use( require( "markdown-it-anchor" ) );
markdownLibrary.use( require( "markdown-it-attrs" ) );
config.setLibrary( "md", markdownLibrary );
return {
dir: {
input: "src",
output: "dist",
},
markdownTemplateEngine: "njk",
templateFormats: ["njk", "md"],
};
};