forked from cmaxw/devchat-eleventy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
107 lines (91 loc) · 3.1 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const moment = require('moment');
const nunjucksDate = require('nunjucks-date');
nunjucksDate.setDefaultFormat('MMM Do YYYY');
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('images');
eleventyConfig.addPassthroughCopy('css');
eleventyConfig.addPassthroughCopy('js');
eleventyConfig.addPassthroughCopy('fonts');
eleventyConfig.addPassthroughCopy('admin');
eleventyConfig.addPassthroughCopy('_redirects');
eleventyConfig.addNunjucksFilter('date', nunjucksDate);
eleventyConfig.addNunjucksFilter('sitemapdate', (dateobj) => {
return moment(dateobj).format("YYYY-MM-DD");
});
eleventyConfig.addFilter('head', (array, n) => {
if (n < 0) {
return array.slice(n);
}
return array.slice(0, n);
});
eleventyConfig.addFilter('embed_youtube', (key) => {
return '<iframe width="825" height="550" src="https://www.youtube.com/embed/' + key + '" frameborder="0" allowfullscreen></iframe><br/>';
});
eleventyConfig.addNunjucksFilter("strip", function(value) { return value.trim() });
eleventyConfig.addFilter('range', (array, m, n) => {
if (n < 0) {
return array.slice(n);
}
return array.slice(m, n);
});
var podcastList = ["adv_in_angular",
"adventures_in_blockchain",
"adventures_in_devops",
"adventures_in_dotnet",
"dev_rev",
"dev_ed",
"elixir_mix",
"freelancers",
"iphreaks",
"js_jabber",
"my_angular_story",
"my_javascript_story",
"my_ruby_story",
"rails_clips",
"react_native_radio",
"react_round_up",
"remote_conf_talks",
"ruby_rogues",
"sustain_our_software",
"teachmetocode",
"tmtc-screencasts",
"views_on_vue",
"web_sec_warriors"];
var today = moment();
podcastList.forEach(function(podcast, index) {
eleventyConfig.addCollection(podcast, function(collection) {
return collection.getFilteredByTag(podcast).sort(function(a, b) {
return b.date - a.date;
}).filter(function(item) {
return item.date <= today;
});
});
});
eleventyConfig.addCollection("podcast", function(collection) {
return collection.getFilteredByTag("podcast").sort(function(a, b) {
return a.date - b.date;
}).filter(function(item) {
return item.date <= today;
});
});
eleventyConfig.addCollection("published", function(collection) {
return collection.getAll().sort(function(a, b) {
return a.date - b.date;
}).filter(function(item) {
return item.date <= today;
});
});
return {
templateFormats: ['md', 'njk', 'html', 'liquid'],
markdownTemplateEngine: 'liquid',
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
passthroughFileCopy: true,
dir: {
input: 'src',
includes: '_includes',
data: '_data',
output: '_site'
}
};
};