This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eleventy.js
71 lines (64 loc) · 2.42 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
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginRss = require("@11ty/eleventy-plugin-rss");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPassthroughCopy("assets");
eleventyConfig.addPassthroughCopy("./src/**/*.jpg");
eleventyConfig.addPassthroughCopy("./src/**/*.png");
eleventyConfig.addPassthroughCopy("./src/**/*.gif");
eleventyConfig.addPassthroughCopy("./src/**/*.mp4");
eleventyConfig.addPassthroughCopy("./src/**/*.pdf");
eleventyConfig.addPassthroughCopy("./src/**/*.mmd");
eleventyConfig.addPassthroughCopy("./src/**/*.xml");
eleventyConfig.addPassthroughCopy("./src/**/*.xslx");
eleventyConfig.addFilter("dateToYear", function (date) {
return moment(date).format("YYYY");
});
// add support for syntax highlighting
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addShortcode("getURLsFromSources", function(sourceObjs) {
//console.log(sourceObjs);
let justUrls = sourceObjs.sources.map((source)=>{
if(typeof source.speedlifyUrl === "string"){
return source.speedlifyUrl;
}
});
justUrls = justUrls.sort().filter(function(item, pos, ary) {
return !pos || item != ary[pos - 1];
});
justUrls = justUrls.filter((url)=>{
if(url){
return true;//
}
});
justUrls.push("https://community.servicenow.com/community");
return JSON.stringify(justUrls);
});
const Image = require("@11ty/eleventy-img");
module.exports = function(eleventyConfig) {
eleventyConfig.addNunjucksAsyncShortcode("myImage", async function(src, alt, outputFormat = "jpeg") {
let stats = await Image(src, {
formats: [outputFormat],
widths: [360, null],
urlPath: "/img/",
outputDir: "img/",
});
let props = stats[outputFormat].pop();
if (alt === undefined) {
throw new Error(`Missing \`alt\` on myImage from: ${src}`);
}
return `<img src="${props.src}" width="${props.width}" height="${props.height}" alt="${alt}">`;
});
};
return {
addPassthroughCopy: true,
markdownTemplateEngine: "njk",
templateFormats: ["njk", "md"],
dir: {
input: "src", // html and layouts for project
output: "_site",
include: "includes",
data: "_data"
}
}
}