|
1 | 1 | const pluginRss = require("@11ty/eleventy-plugin-rss"); |
2 | 2 |
|
3 | | -module.exports = function(eleventyConfig) { |
4 | | - /* ==== Static passthrough (لازم) ==== */ |
5 | | - eleventyConfig.addPassthroughCopy({ "css": "css" }); |
6 | | - eleventyConfig.addPassthroughCopy({ "js": "js" }); |
7 | | - eleventyConfig.addPassthroughCopy({ "img": "img" }); |
8 | | - eleventyConfig.addPassthroughCopy({ "files": "files" }); // لو موجود |
9 | | - |
10 | | - /* ==== Watch targets ==== */ |
| 3 | +module.exports = function (eleventyConfig) { |
| 4 | + // Static passthrough |
| 5 | + eleventyConfig.addPassthroughCopy("css"); |
| 6 | + eleventyConfig.addPassthroughCopy("js"); |
| 7 | + eleventyConfig.addPassthroughCopy("img"); |
| 8 | + eleventyConfig.addPassthroughCopy("files"); |
| 9 | + |
| 10 | + // Watch targets |
11 | 11 | eleventyConfig.addWatchTarget("css"); |
12 | 12 | eleventyConfig.addWatchTarget("js"); |
13 | 13 | eleventyConfig.addWatchTarget("img/showreel"); |
14 | 14 |
|
15 | | - /* ==== RSS filters & fixes (علاج absoluteUrl/htmlDate/readableDate) ==== */ |
| 15 | + // RSS plugin + filters |
16 | 16 | eleventyConfig.addPlugin(pluginRss); |
17 | | - eleventyConfig.addFilter("absoluteUrl", (url, base) => pluginRss.absoluteUrl(url, base)); |
| 17 | + |
| 18 | + eleventyConfig.addFilter("absoluteUrl", (url, base) => |
| 19 | + pluginRss.absoluteUrl(url, base) |
| 20 | + ); |
| 21 | + |
18 | 22 | eleventyConfig.addFilter("htmlDateString", (dateObj) => { |
19 | | - try { return new Date(dateObj).toISOString(); } catch { return ""; } |
| 23 | + try { |
| 24 | + return new Date(dateObj).toISOString(); |
| 25 | + } catch { |
| 26 | + return ""; |
| 27 | + } |
20 | 28 | }); |
| 29 | + |
21 | 30 | eleventyConfig.addFilter("readableDate", (dateObj) => { |
22 | 31 | try { |
23 | 32 | const d = new Date(dateObj); |
24 | | - return new Intl.DateTimeFormat("en-GB", { day:"2-digit", month:"short", year:"numeric" }).format(d); |
25 | | - } catch { return ""; } |
| 33 | + return new Intl.DateTimeFormat("en-GB", { |
| 34 | + day: "2-digit", |
| 35 | + month: "short", |
| 36 | + year: "numeric", |
| 37 | + }).format(d); |
| 38 | + } catch { |
| 39 | + return ""; |
| 40 | + } |
26 | 41 | }); |
27 | 42 |
|
28 | | - /* ==== tagList collection (عشان tags.njk ما يهنّش) ==== */ |
| 43 | + // tagList collection |
29 | 44 | eleventyConfig.addCollection("tagList", (collectionsApi) => { |
30 | 45 | const set = new Set(); |
31 | | - collectionsApi.getAll().forEach(item => (item.data.tags || []).forEach(t => set.add(t))); |
| 46 | + collectionsApi.getAll().forEach((item) => { |
| 47 | + (item.data.tags || []).forEach((t) => set.add(t)); |
| 48 | + }); |
32 | 49 | return [...set]; |
33 | 50 | }); |
34 | 51 |
|
35 | | - /* ==== Server options (نقفل liveReload اللي كان عامل RSV1) ==== */ |
| 52 | + // Eleventy config |
36 | 53 | return { |
37 | 54 | dir: { input: ".", includes: "_includes", data: "_data", output: "_site" }, |
38 | | - serverOptions: { liveReload: false, domDiff: false, port: 8087 } |
| 55 | + serverOptions: { liveReload: false, domDiff: false, port: 8087 }, |
39 | 56 | }; |
40 | 57 | }; |
0 commit comments