-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
51 lines (42 loc) · 1.5 KB
/
eleventy.config.js
File metadata and controls
51 lines (42 loc) · 1.5 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
const path = require("path");
module.exports = function(eleventyConfig) {
// --- Collections ---
// Create a collection of students, sorted by their name
eleventyConfig.addCollection("students", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/content/students/*.md").sort((a, b) => {
if (a.data.studentName < b.data.studentName) { return -1; }
if (a.data.studentName > b.data.studentName) { return 1; }
return 0;
});
});
// --- Passthrough Copy ---
// Copy the student images to the output directory
eleventyConfig.addPassthroughCopy("public/uploads");
// --- Path Prefix for GitHub Pages ---
// This is important for your site to work correctly on a subdomain/subfolder.
// Replace 'fce-students' with your actual repository name.
const repoName = path.basename(__dirname);
const pathPrefix = process.env.NODE_ENV === 'production' ? `/${repoName}/` : '/';
console.log(`Using pathPrefix: ${pathPrefix}`);
return {
// Control which files Eleventy processes
templateFormats: [
"md",
"njk",
"html"
],
// Pre-process data files with Nunjucks
dataTemplateEngine: "njk",
// Pre-process Markdown files with Nunjucks
markdownTemplateEngine: "njk",
// Directory settings
dir: {
input: "src",
includes: "_includes",
data: "_data",
output: "_site" // This is the default, but good to be explicit
},
// Path prefix for deployment
pathPrefix: pathPrefix
};
};