-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
86 lines (70 loc) · 3.88 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
const { EleventyRenderPlugin } = require("@11ty/eleventy");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const Nunjucks = require("nunjucks");
const buildBreadcrumbs = require('./src/static/js/building/breadcrumbs.js');
const buildTreemap = require('./src/static/js/building/treemap.js');
const buildChangelog = require('./src/static/js/building/changelog.js');
const { buildTagWall, getRecents, getRelated, buildTimestamps } = require('./src/static/js/building/tilling.js');
const addAsset = require('./src/static/js/building/linking.js');
const { qka, quizButtons, quizQuestions } = require('./src/static/js/building/quizzing.js');
const { buildVersionTag, buildKeywords } = require("./src/static/js/building/package.js");
const { projectImages, getFeaturedProjects, getMainProjects, getOtherProjects } = require("./src/static/js/building/projects.js");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addGlobalData("eleventyComputed", {
eleventyNavigation: {
key: data => data.eleventyNavigation.key || data.page.fileSlug,
parent: data => data.eleventyNavigation.parent || data.page.parent,
title: data => data.eleventyNavigation.title || data.title,
}
});
eleventyConfig.addPassthroughCopy("./src/static/js"); // css is compiled by sass
eleventyConfig.addPassthroughCopy("./assets");
eleventyConfig.addPassthroughCopy("**.json");
eleventyConfig.setQuietMode(true); // suppresses the "Writing" log message
eleventyConfig.setDataFileSuffixes([".data", ""]);
eleventyConfig.setServerOptions({ watch: ["src/static/css/**"], port: 8088 });
eleventyConfig.addShortcode("breadcrumbs", buildBreadcrumbs);
eleventyConfig.addShortcode("treemap", buildTreemap);
eleventyConfig.addShortcode("changelog", buildChangelog);
eleventyConfig.addShortcode("tilTags", buildTagWall);
eleventyConfig.addShortcode("tilRecents", getRecents);
eleventyConfig.addShortcode("tilRelated", getRelated);
eleventyConfig.addShortcode("tilTimestamps", buildTimestamps);
eleventyConfig.addShortcode("qka", qka);
eleventyConfig.addShortcode("quizButtons", quizButtons);
eleventyConfig.addShortcode("quizQuestions", quizQuestions);
eleventyConfig.addShortcode("addScript", (filename) => addAsset("script", filename));
eleventyConfig.addShortcode("addStyle", (filename) => addAsset("style", filename));
eleventyConfig.addShortcode("keywords", buildKeywords);
eleventyConfig.addShortcode("version", buildVersionTag);
eleventyConfig.addShortcode("ref", (url, num) => `<a href="${url}" class="ref" target="_blank" rel="noopener noreferrer">[${num}]</a>`);
eleventyConfig.addShortcode("tilImg", function (file, alt) {
return `<figure class="til-img">
<img src="/assets/media/projects/til/${this.page.fileSlug}/${file}" alt="${alt}" />
<figcaption class="til-img-alt">${alt}</figcaption>
</figure>`;
});
eleventyConfig.addShortcode("link", (url, text) => `<a href="${url}" target="_blank" rel="noopener noreferrer">${text}</a>`);
eleventyConfig.addShortcode("projectImages", projectImages);
eleventyConfig.addFilter("generateDesc", function (content) {
if (!content) return "personal portfolio website that collects all my projects and professional experiences.";
let text = content.replace(/<[^>]*>/g, '').trim();
return text.slice(0, 160) + (text.length > 160 ? "..." : "");
});
eleventyConfig.addFilter("featuredProjects", getFeaturedProjects);
eleventyConfig.addFilter("mainProjects", getMainProjects);
eleventyConfig.addFilter("otherProjects", getOtherProjects);
eleventyConfig.setLibrary("njk", new Nunjucks.Environment(
new Nunjucks.FileSystemLoader("./"),
{ lstripBlocks: true, trimBlocks: true }
));
return {
dir: {
input: "src",
includes: "templates",
data: "content/data"
}
};
};