5panda.11ty/.eleventy.js

118 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

const markdownIt = require("markdown-it");
const markdownItMermaid = require("markdown-it-mermaid");
2025-12-17 16:52:19 +07:00
module.exports = function (eleventyConfig) {
// Passthrough copy for static assets
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/js");
// Watch targets
2025-12-16 15:28:43 +07:00
eleventyConfig.addWatchTarget("src/css");
// Global Permalink: Use .html extension instead of nested index.html files
eleventyConfig.addGlobalData("permalink", () => {
return "{{ page.filePathStem }}.html";
});
2025-12-17 16:52:19 +07:00
// Add year shortcode
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
// Add date filter for formatting
eleventyConfig.addFilter("dateFormat", (date, format = "full") => {
const d = new Date(date);
const options = {
full: { year: 'numeric', month: 'long', day: 'numeric' },
short: { year: 'numeric', month: 'short', day: 'numeric' },
iso: null,
};
if (format === "iso") {
return d.toISOString().split('T')[0];
}
return d.toLocaleDateString('en-US', options[format] || options.full);
});
// Add reading time filter
eleventyConfig.addFilter("readingTime", (content) => {
if (!content) return "1 min read";
const words = content.split(/\s+/).length;
const minutes = Math.ceil(words / 200);
return `${minutes} min read`;
});
// Add excerpt filter
eleventyConfig.addFilter("excerpt", (content, length = 150) => {
if (!content) return "";
const text = content.replace(/<[^>]+>/g, '').replace(/\n/g, ' ').trim();
return text.length > length ? text.slice(0, length) + '...' : text;
});
// Add head filter (get first n items from array)
eleventyConfig.addFilter("head", (array, n) => {
if (!Array.isArray(array)) return [];
if (n < 0) {
return array.slice(n);
}
return array.slice(0, n);
});
// Markdown: enable Mermaid diagrams
const mermaidPlugin = markdownItMermaid.default || markdownItMermaid;
const markdownLib = markdownIt({
html: true,
breaks: false,
linkify: true
}).use(mermaidPlugin);
eleventyConfig.setLibrary("md", markdownLib);
2025-12-17 16:52:19 +07:00
// Collections
// Blog posts / Proposals collection
eleventyConfig.addCollection("posts", function (collectionApi) {
return collectionApi.getFilteredByGlob("src/blog/**/*.md").sort((a, b) => {
return new Date(b.date) - new Date(a.date);
});
});
// Projects collection (blog posts + CLQMS + TinyLink)
refactor: restructure CLQMS documentation under projects directory This commit reorganizes the CLQMS documentation structure and removes redundant review content: ### Architecture Changes - Added `projects` collection to Eleventy config combining blog posts and CLQMS-tagged content - Renamed `??` nullish coalescing operator in collection sorting for consistency - Simplified navigation in `base.njk` - replaced individual post links with single CLQMS overview link - Removed deprecated `/blog/clqms01/` overview link from `clqms-post.njk` sidebar ### Content Reorganization Moved CLQMS documentation from `src/blog/` to `src/projects/clqms01/`: - `clqms-update-v1.md` → `001-architecture.md` - `clqms-module-auth.md` → `002-auth-module.md` - `clqms-frontend-stack.md` → `003-frontend-stack.md` - Added new documentation: `004-wst-concept.md`, `005-wst-database.md`, `006-test-api-examples.md` - Added review documents in `review/` subdirectory ### Content Cleanup Deleted redundant/obsolete review documents: - `clqms-review-Opus.md` (374 lines - database schema review) - `clqms-review-Sonnet.md` (1305 lines - comprehensive schema assessment) - `clqms-roast-Opus.md` - `clqms-roast-zai.md` - `clqms-wst-concept.md` (consolidated into projects directory) - `clqms-wst-database.md` (consolidated into projects directory) - `clqms01.md` (consolidated into projects directory) ### New Project Files - `.claude/settings.json` - Claude Code environment configuration - `CLAUDE.md` - Project documentation for AI assistants Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 16:44:37 +07:00
eleventyConfig.addCollection("projects", function (collectionApi) {
const blogPosts = collectionApi.getFilteredByGlob("src/blog/**/*.md");
const clqmsPosts = collectionApi.getFilteredByTag("clqms");
const tinylinkPosts = collectionApi.getFilteredByTag("tinylink");
refactor: restructure CLQMS documentation under projects directory This commit reorganizes the CLQMS documentation structure and removes redundant review content: ### Architecture Changes - Added `projects` collection to Eleventy config combining blog posts and CLQMS-tagged content - Renamed `??` nullish coalescing operator in collection sorting for consistency - Simplified navigation in `base.njk` - replaced individual post links with single CLQMS overview link - Removed deprecated `/blog/clqms01/` overview link from `clqms-post.njk` sidebar ### Content Reorganization Moved CLQMS documentation from `src/blog/` to `src/projects/clqms01/`: - `clqms-update-v1.md` → `001-architecture.md` - `clqms-module-auth.md` → `002-auth-module.md` - `clqms-frontend-stack.md` → `003-frontend-stack.md` - Added new documentation: `004-wst-concept.md`, `005-wst-database.md`, `006-test-api-examples.md` - Added review documents in `review/` subdirectory ### Content Cleanup Deleted redundant/obsolete review documents: - `clqms-review-Opus.md` (374 lines - database schema review) - `clqms-review-Sonnet.md` (1305 lines - comprehensive schema assessment) - `clqms-roast-Opus.md` - `clqms-roast-zai.md` - `clqms-wst-concept.md` (consolidated into projects directory) - `clqms-wst-database.md` (consolidated into projects directory) - `clqms01.md` (consolidated into projects directory) ### New Project Files - `.claude/settings.json` - Claude Code environment configuration - `CLAUDE.md` - Project documentation for AI assistants Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 16:44:37 +07:00
const allProjects = [...blogPosts, ...clqmsPosts, ...tinylinkPosts].sort((a, b) => {
refactor: restructure CLQMS documentation under projects directory This commit reorganizes the CLQMS documentation structure and removes redundant review content: ### Architecture Changes - Added `projects` collection to Eleventy config combining blog posts and CLQMS-tagged content - Renamed `??` nullish coalescing operator in collection sorting for consistency - Simplified navigation in `base.njk` - replaced individual post links with single CLQMS overview link - Removed deprecated `/blog/clqms01/` overview link from `clqms-post.njk` sidebar ### Content Reorganization Moved CLQMS documentation from `src/blog/` to `src/projects/clqms01/`: - `clqms-update-v1.md` → `001-architecture.md` - `clqms-module-auth.md` → `002-auth-module.md` - `clqms-frontend-stack.md` → `003-frontend-stack.md` - Added new documentation: `004-wst-concept.md`, `005-wst-database.md`, `006-test-api-examples.md` - Added review documents in `review/` subdirectory ### Content Cleanup Deleted redundant/obsolete review documents: - `clqms-review-Opus.md` (374 lines - database schema review) - `clqms-review-Sonnet.md` (1305 lines - comprehensive schema assessment) - `clqms-roast-Opus.md` - `clqms-roast-zai.md` - `clqms-wst-concept.md` (consolidated into projects directory) - `clqms-wst-database.md` (consolidated into projects directory) - `clqms01.md` (consolidated into projects directory) ### New Project Files - `.claude/settings.json` - Claude Code environment configuration - `CLAUDE.md` - Project documentation for AI assistants Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 16:44:37 +07:00
return new Date(b.date) - new Date(a.date);
});
return allProjects;
});
// CLQMS collection sorted by order
eleventyConfig.addCollection("clqms", function (collectionApi) {
return collectionApi.getFilteredByTag("clqms").sort((a, b) => {
refactor: restructure CLQMS documentation under projects directory This commit reorganizes the CLQMS documentation structure and removes redundant review content: ### Architecture Changes - Added `projects` collection to Eleventy config combining blog posts and CLQMS-tagged content - Renamed `??` nullish coalescing operator in collection sorting for consistency - Simplified navigation in `base.njk` - replaced individual post links with single CLQMS overview link - Removed deprecated `/blog/clqms01/` overview link from `clqms-post.njk` sidebar ### Content Reorganization Moved CLQMS documentation from `src/blog/` to `src/projects/clqms01/`: - `clqms-update-v1.md` → `001-architecture.md` - `clqms-module-auth.md` → `002-auth-module.md` - `clqms-frontend-stack.md` → `003-frontend-stack.md` - Added new documentation: `004-wst-concept.md`, `005-wst-database.md`, `006-test-api-examples.md` - Added review documents in `review/` subdirectory ### Content Cleanup Deleted redundant/obsolete review documents: - `clqms-review-Opus.md` (374 lines - database schema review) - `clqms-review-Sonnet.md` (1305 lines - comprehensive schema assessment) - `clqms-roast-Opus.md` - `clqms-roast-zai.md` - `clqms-wst-concept.md` (consolidated into projects directory) - `clqms-wst-database.md` (consolidated into projects directory) - `clqms01.md` (consolidated into projects directory) ### New Project Files - `.claude/settings.json` - Claude Code environment configuration - `CLAUDE.md` - Project documentation for AI assistants Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 16:44:37 +07:00
return (Number(a.data.order) ?? 99) - (Number(b.data.order) ?? 99);
});
});
// TinyLink collection sorted by order
eleventyConfig.addCollection("tinylink", function (collectionApi) {
return collectionApi.getFilteredByTag("tinylink").sort((a, b) => {
return (Number(a.data.order) ?? 99) - (Number(b.data.order) ?? 99);
});
});
2025-12-16 15:28:43 +07:00
return {
dir: {
input: "src",
output: "_site",
includes: "_includes",
2025-12-17 16:52:19 +07:00
layouts: "_layouts",
data: "_data"
},
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
templateFormats: ["html", "njk", "md"]
2025-12-16 15:28:43 +07:00
};
};