-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy path.eleventy.js
More file actions
131 lines (112 loc) · 7.34 KB
/
.eleventy.js
File metadata and controls
131 lines (112 loc) · 7.34 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
// ─────────────────────────────────────────────────────────────────────────────
// ELEVENTY CONFIGURATION
// This file configures how Eleventy builds your static site
// Documentation: https://www.11ty.dev/docs/config/
// ─────────────────────────────────────────────────────────────────────────────
// 📦 Plugin Imports
const pluginImages = require("@codestitchofficial/eleventy-plugin-sharp-images");
const pluginMinifier = require("@codestitchofficial/eleventy-plugin-minify");
const pluginSitemap = require("@quasibit/eleventy-plugin-sitemap");
// ⚙️ Configuration Files
const configSitemap = require("./src/config/plugins/sitemap");
const configImages = require("./src/config/plugins/images");
// 🔧 Processing Functions
const sass = require("./src/config/processors/sass");
const javascript = require("./src/config/processors/javascript");
// 🛠️ Utilities
const filterPostDate = require("./src/config/filters/postDate");
const filterIsoDate = require("./src/config/filters/isoDate");
const isProduction = process.env.ELEVENTY_ENV === "PROD";
module.exports = function (eleventyConfig) {
// ═════════════════════════════════════════════════════════════════════════
// LANGUAGES
// Using Eleventy's build events to process non-template languages
// Learn more: https://www.11ty.dev/docs/events/
// ═════════════════════════════════════════════════════════════════════════
/*
* JavaScript & CSS Processing
* These processors handle bundling, transpiling, and minification
* - JavaScript: Compiled with esbuild for modern bundling
* - CSS/SASS: Processed and minified for production, including a PostCSS pipeline
*/
eleventyConfig.on("eleventy.after", javascript);
eleventyConfig.on("eleventy.after", sass);
// ═════════════════════════════════════════════════════════════════════════
// PLUGINS
// Extend Eleventy with additional functionality
// Learn more: https://www.11ty.dev/docs/plugins/
// ═════════════════════════════════════════════════════════════════════════
/*
* 🖼️ Image Optimization
* Resize and optimize images for better performance using {% getUrl %}
* Documentation: https://github.com/CodeStitchOfficial/eleventy-plugin-sharp-images
*/
eleventyConfig.addPlugin(pluginImages, configImages);
/*
* 🗺️ Sitemap Generation
* Creates sitemap.xml automatically using domain from _data/client.json
* Documentation: https://github.com/quasibit/eleventy-plugin-sitemap
*/
eleventyConfig.addPlugin(pluginSitemap, configSitemap);
/*
* 📦 Production Minification
* Minifies HTML, CSS, JSON, XML, XSL, and webmanifest files
* Only runs during production builds (npm run build)
* Documentation: https://github.com/CodeStitchOfficial/eleventy-plugin-minify
*/
if (isProduction) {
eleventyConfig.addPlugin(pluginMinifier);
}
// ═════════════════════════════════════════════════════════════════════════
// PASSTHROUGH COPIES
// Copy files directly to output without processing
// Learn more: https://www.11ty.dev/docs/copy/
// ═════════════════════════════════════════════════════════════════════════
eleventyConfig.addPassthroughCopy("./src/assets"); // Static assets
eleventyConfig.addPassthroughCopy("./src/admin"); // CMS admin files
eleventyConfig.addPassthroughCopy("./src/_redirects"); // Redirect rules
// ═════════════════════════════════════════════════════════════════════════
// FILTERS
// Transform data in templates at build time
// Learn more: https://www.11ty.dev/docs/filters/
// ═════════════════════════════════════════════════════════════════════════
/*
* 📅 Human-Readable Date Formatting Filter
* Converts JavaScript dates to human-readable format
* Usage: {{ "2023-12-02" | postDate }}
* Powered by Luxon: https://moment.github.io/luxon/api-docs/
*/
eleventyConfig.addFilter("postDate", filterPostDate);
/*
* 📅 ISO Date Formatting Filter
* Converts JavaScript dates to ISO 8601 format
* Usage: {{ "2023-12-02" | isoDate }}
* Powered by Luxon: https://moment.github.io/luxon/api-docs/
*/
eleventyConfig.addFilter("isoDate", filterIsoDate);
// ═════════════════════════════════════════════════════════════════════════
// SHORTCODES
// Generate dynamic content with JavaScript
// Learn more: https://www.11ty.dev/docs/shortcodes/
// ═════════════════════════════════════════════════════════════════════════
/*
* 📆 Current Year Shortcode
* Outputs the current year (useful for copyright notices)
* Usage: {% year %}
* Updates automatically with each build
*/
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
// ═════════════════════════════════════════════════════════════════════════
// BUILD CONFIGURATION
// Define input/output directories and template engine
// ═════════════════════════════════════════════════════════════════════════
return {
dir: {
input: "src", // Source files directory
output: "public", // Build output directory
includes: "_includes", // Partial templates directory
data: "_data", // Global data files directory
},
htmlTemplateEngine: "njk", // Nunjucks for HTML templates
};
};