GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fevrcoding.github.io/.eleventy.js at master · fevrcoding/fevrcoding.github.io

This repository was archived by the owner on May 2, 2021. It is now read-only.

Expand file tree

/

.eleventy.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
156 lines (133 loc) · 3.9 KB
/

.eleventy.js

Copy path

File metadata and controls

156 lines (133 loc) · 3.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
const yaml = require('js-yaml');
const { join } = require('path');
const rss = require('@11ty/eleventy-plugin-rss');
const { DateTime } = require('luxon');
const Image = require('@11ty/eleventy-img');
const markdown = require('markdown-it')({
html: true,
});
const WEEK = [
'Lunedì',
'Martedì',
'Mercoledì',
'Giovedì',
'Venerdì',
'Sabato',
'Domenica',
];
const MONTHS = [
'Gennaio',
'Febbraio',
'Marzo',
'Aprile',
'Maggio',
'Giugno',
'Luglio',
'Agosto',
'Settembre',
'Ottobre',
'Novembre',
'Dicembre',
];
module.exports = function (eleventyConfig) {
const assets = ['js', 'css', 'fonts', 'img', 'odx-assets', 'admin'];
for (const folder of assets) {
eleventyConfig.addPassthroughCopy({ [`static/${folder}`]: folder });
}
eleventyConfig.addNunjucksAsyncShortcode(
'image',
async function (
src,
alt,
imgClass = 'img-rounded img-responsive center-block',
) {
if (alt === undefined) {
// You bet we throw an error on missing alt (alt="" works okay)
throw new Error(`Missing \`alt\` on myImage from: ${src}`);
}
const image = await Image(join('static', src), {
widths: [null],
formats: ['webp', 'jpeg'],
urlPath: '/img/',
outputDir: './_site/img/',
});
const { url, width, height } = image.jpeg[0];
return `<picture>
<source srcset="${image.webp[0].url}" type="image/webp" />
<img class="${imgClass}" src="${url}" width="${width}" height="${height}" alt="${alt}" loading="lazy" />
</picture>`;
},
);
eleventyConfig.addPlugin(rss);
eleventyConfig.addPassthroughCopy({ 'static/*.*': '.' });
eleventyConfig.addWatchTarget('./src/_js/');
eleventyConfig.addDataExtension('yaml', (contents) =>
yaml.safeLoad(contents),
);
eleventyConfig.addNunjucksShortcode('markdown', (content) =>
markdown.render(content),
);
eleventyConfig.addNunjucksFilter('dateformat', (date, format) => {
return DateTime.fromJSDate(date, { zone: 'Europe/Rome' }).toFormat(format);
});
eleventyConfig.addNunjucksFilter('date_human', (start, end) => {
const startDate = DateTime.fromJSDate(start, {
zone: 'Europe/Rome',
});
const startLocale = `${
WEEK[startDate.weekday - 1]
} ${startDate.day.toString().padStart(2, '0')} ${
MONTHS[startDate.month - 1]
} ${startDate.year}`;
const startTime = startDate.toFormat('HH:mm');
if (!end) {
return `${startLocale} alle ${startTime}`;
}
const endTime = DateTime.fromJSDate(end, { zone: 'Europe/Rome' }).toFormat(
'HH:mm',
);
return `${startLocale} dalle ${startTime} alle ${endTime}`;
});
eleventyConfig.addFilter('dateslug', (date) => {
return DateTime.fromJSDate(date, { zone: 'Europe/Rome' }).toFormat(
'yyyy/LL',
);
});
eleventyConfig.addNunjucksFilter('published', (posts) => {
return posts.filter((post) => post.data.published);
});
eleventyConfig.addNunjucksFilter('limit', (posts, num) => {
return posts.slice(0, num);
});
eleventyConfig.addNunjucksFilter('featuredEvent', (posts) => {
// return a featured event or the first one
return posts.find(({ data }) => data.featured) || posts[0];
});
// redirect collection
eleventyConfig.addCollection('redirects', function (collection) {
const redirs = collection.getAll().filter(({ data }) => data.redirect_from);
const redirects = new Map();
for (item of redirs) {
let { redirect_from } = item.data;
if (!Array.isArray(redirect_from)) {
redirect_from = [redirect_from];
}
redirect_from.forEach((from) => {
redirects.set(from, {
from,
to: item.url,
});
});
}
return [...redirects.values()];
});
return {
htmlTemplateEngine: 'njk',
dir: {
includes: '_includes',
layouts: '_layouts',
input: 'src',
output: '_site',
},
};
};
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.