-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
137 lines (112 loc) · 4.53 KB
/
.eleventy.js
File metadata and controls
137 lines (112 loc) · 4.53 KB
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
import pugPlugin from "@11ty/eleventy-plugin-pug";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
import * as sass from "sass";
import purgeCssPlugin from "eleventy-plugin-purgecss";
import eleventySass from "eleventy-sass";
import path from 'node:path';
import fs from 'node:fs';
import url from 'node:url';
let default_title = 'James J Nadeau | Senior Systems Engineer'
let default_description = ''
export default async function(eleventyConfig) {
// add navigation plugin
eleventyConfig.addPlugin(eleventyNavigationPlugin);
// set input/ouput directories
eleventyConfig.setInputDirectory("content");
eleventyConfig.setOutputDirectory("_site");
// use pug plugin,
global.eleventyNavigationPlugin = eleventyNavigationPlugin.navigation; // see https://github.com/11ty/eleventy-plugin-template-languages/issues/1#issuecomment-2221156643
eleventyConfig.addPlugin(pugPlugin, {
debug: true,
// filters: eleventyConfig.filters,
globals: ['eleventyNavigationPlugin']
// {
// 'eleventyNavigation': function (text) {
// return text
// },
// }
});
// set global layout
eleventyConfig.addGlobalData("layout", "layouts/main.pug");
// defaul title/descriptions
eleventyConfig.addGlobalData("title", default_title);
eleventyConfig.addGlobalData("description", default_description);
// configure bundles - not currently used?
eleventyConfig.addBundle("css");
eleventyConfig.addBundle("js");
// Directory Passthroughs
// Copy `static/` to `_site/subfolder/img`
eleventyConfig.addPassthroughCopy({ static: "/" });
// add sass config, see https://www.11ty.dev/docs/languages/custom/#example-add-sass-support-to-eleventy
eleventyConfig.addTemplateFormats("scss");
let node_modules_path = './node_modules'
eleventyConfig.addPlugin(eleventySass, {
sass: {
loadPaths: [node_modules_path],
quietDeps: true,
style: "compressed",
sourceMap: true,
},
});
// Legacy method perscribed in eleventy docs, above works better and has source maps
// Creates the extension for use
// eleventyConfig.addExtension("scss", {
// outputFileExtension: "css", // default: "html"
// // `compile` is called once per .scss file in the input directory
// compile: async function (inputContent) {
// // This is the render function, `data` is the full data cascade
// const compiler = await sass.initAsyncCompiler();
// return async (data) => {
// // console.log()
// let my_path = path.dirname(data.page.inputPath)
// // let result = sass.compileString(inputContent, {
// let result = await compiler.compileAsync(data.page.inputPath, {
// loadPaths: [my_path, node_modules_path],
// quietDeps: true,
// sourceMap: true,
// style: 'compressed',
// });
// let inputURL = url.pathToFileURL(path.resolve(data.page.inputPath)).href;
// // await new Promise(function(resolve, reject) {
// // fs.writeFile(`${data.page.outputPath}.map`, result.sourceMap.sourcesContent, resolve);
// // });
// return result.css;
// };
// },
// });
// purge-css
if (process.env.NODE_ENV === "production") {
eleventyConfig.addPlugin(purgeCssPlugin, {
// Optional: Specify the location of your PurgeCSS config
config: {
// Content files referencing CSS classes
content: ["./_site/**/*.html", "./_site/**/*.js"],
// CSS files to be purged in-place
css: ["./_site/**/*.css"],
},
// Optional: Set quiet: true to suppress terminal output
quiet: false,
});
}
// rss feed
eleventyConfig.addPlugin(feedPlugin, {
type: "rss", // or "atom", "json"
outputPath: "/til/rss.xml",
collection: {
name: "TIL", // iterate over `collections.posts`
limit: 10, // 0 means no limit
},
metadata: {
language: "en",
title: "Today I ... by James Nadeau",
subtitle: "A collection of things I found interesting at the time..",
base: "https://jamesjnadeau.com/",
author: {
name: "James Nadeau",
email: "", // Optional
}
}
});
// console.log(eleventyConfig)
};