-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
68 lines (58 loc) · 2.61 KB
/
Copy path.eleventy.js
File metadata and controls
68 lines (58 loc) · 2.61 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
const MarkdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
const { DateTime } = require("luxon");
module.exports = function(eleventyConfig){
// Configure markdown parsing options to match professional agency templates
const markdownLibrary = MarkdownIt({
html: true, // Ensures inline HTML elements pass through cleanly
breaks: true, // Turns double returns into paragraphs automatically
linkify: true // Auto-converts text URLs into clickable links
}).use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.headerLink() // Automatically generates heading-anchors!
});
// Force Eleventy to use this library for all markdown files and template blocks
eleventyConfig.setLibrary("md", markdownLibrary);
eleventyConfig.addFilter("markdown", (content) => markdownLibrary.render(content || ""));
eleventyConfig.addPassthroughCopy('./src/css/styles.css')
eleventyConfig.addPassthroughCopy('./src/assets')
eleventyConfig.addPassthroughCopy('./src/admin');
eleventyConfig.addFilter("postDate", (dateObj) => {
return DateTime.fromJSDate(dateObj).toLocaleString(DateTime.DATE_MED);
});
// Add this inside your .eleventy.js configuration function
eleventyConfig.addCollection("locations", function(collectionApi) {
// Pulls all markdown files directly from your src/locations/ directory
return collectionApi.getFilteredByGlob("src/locations/*.md");
});
// ADD THIS BLOCK FOR YOUR SERVICES
eleventyConfig.addCollection("services", function(collectionApi) {
// Pulls all markdown files directly from your src/services/ directory
return collectionApi.getFilteredByGlob("src/services/*.md");
});
// Minify HTML output (conservative: collapse indentation whitespace but keep
// inline spacing, strip HTML comments; inline JS/CSS left untouched to be safe).
eleventyConfig.addTransform("htmlmin", async function(content){
if ((this.page.outputPath || "").endsWith(".html")) {
try {
const { minify } = await import("html-minifier-terser");
return await minify(content, {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true,
keepClosingSlash: true,
});
} catch (e) {
console.warn(`[htmlmin] skipped ${this.page.inputPath}: ${e.message}`);
return content;
}
}
return content;
});
return{
dir:{
input:"src",
output:"public",
includes: "_includes"
}
}
}