-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.mjs
80 lines (66 loc) · 2.5 KB
/
eleventy.config.mjs
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
import {marked} from 'marked';
import {minify} from 'html-minifier-terser';
import pluginRss from '@11ty/eleventy-plugin-rss';
import EleventyPluginRobotsTxt from "eleventy-plugin-robotstxt";
export default async function(eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(EleventyPluginRobotsTxt, {
sitemapURL: 'https://www.christianhain.com/sitemap.xml',
shouldBlockAIRobots: true,
});
eleventyConfig.addShortcode('year', () => new Date().getFullYear());
eleventyConfig.addTransform('minify', async function (content) {
const outputPath = this.page.outputPath || '';
let options = null;
if (outputPath.endsWith('.html')) {
options = {
minifyJS: true,
removeComments: true,
useShortDoctype: true,
collapseWhitespace: true,
};
} else if (outputPath.endsWith('.xml')) {
options = {
keepClosingSlash: true,
collapseWhitespace: true,
};
}
return (options)
? await minify(content, options)
: content;
});
eleventyConfig.addFilter('atom_dateToRfc3339', (date) => pluginRss.dateToRfc3339(new Date(date)));
eleventyConfig.addFilter('blogListTimestamp', (date) =>
new Date(date).toLocaleString('en-US', {
day: '2-digit',
year: 'numeric',
month: 'short',
})
);
eleventyConfig.addFilter('blogPostTimestamp', (date) =>
new Date(date).toLocaleString('en-US', {
day: 'numeric',
year: 'numeric',
month: 'long',
})
);
eleventyConfig.addFilter('escapeNewlines', (string) => string.replace(/\n/g, "\\n").trim());
eleventyConfig.addFilter('markdown', async (content) => {
return await marked.parse(content)
// Article Theme
.replace('<meta data-xian="article-start">', '</div><div data-theme="article"><div class="blog__copy">')
.replace('<meta data-xian="article-end">', '</div></div><div class="blog__copy" data-theme="memo">')
// Email Theme
.replace('<meta data-xian="email-start">', '</div><div data-theme="email"><div class="blog__copy">')
.replace('<meta data-xian="email-end">', '</div></div><div class="blog__copy" data-theme="memo">')
// Video-Player Theme
.replace('<meta data-xian="videoplayer-start">', '</div><div data-theme="video-player"><div class="blog__copy">')
.replace('<meta data-xian="videoplayer-end">', '</div></div><div class="blog__copy" data-theme="memo">')
});
return {
dir: {
input: 'src/views',
output: 'public',
},
};
}