|
| 1 | + |
| 2 | +module.exports = function (eleventyConfig) { |
| 3 | + |
| 4 | + // SIGHTS - custom collections |
| 5 | + const nowsights = new Date(); |
| 6 | + const sightslivePosts = (post) => post.date <= nowsights; |
| 7 | + eleventyConfig.addCollection("sights", (collection) => { |
| 8 | + return [ |
| 9 | + ...collection.getFilteredByGlob("./sights/*.njk").filter(sightslivePosts), |
| 10 | + ].reverse(); |
| 11 | + }); |
| 12 | + |
| 13 | + // SOUNDS - custom collections |
| 14 | + const nowsounds = new Date(); |
| 15 | + const soundslivePosts = (post) => post.date <= nowsounds; |
| 16 | + eleventyConfig.addCollection("sounds", (collection) => { |
| 17 | + return [ |
| 18 | + ...collection.getFilteredByGlob("./sounds/*.njk").filter(soundslivePosts), |
| 19 | + ].reverse(); |
| 20 | + }); |
| 21 | + |
| 22 | + // generate a list of all tags collections |
| 23 | + // with alphabetical sorting - had to invert to "b, a" because it was sorting upside down |
| 24 | + eleventyConfig.addCollection('tagsList', (collectionApi) => { |
| 25 | + const tagsSet = new Set() |
| 26 | + collectionApi.getAll().forEach((item) => { |
| 27 | + if (!item.data.tags) return |
| 28 | + item.data.tags.forEach((tag) => tagsSet.add(tag)) |
| 29 | + }) |
| 30 | + return [...tagsSet].sort((b, a) => b.localeCompare(a)) |
| 31 | + }); |
| 32 | + |
| 33 | + |
| 34 | +// https://www.11ty.dev/docs/copy/#manual-passthrough-file-copy-(faster) |
| 35 | +eleventyConfig.addPassthroughCopy('assets'); |
| 36 | +eleventyConfig.addPassthroughCopy('sitemap.xml'); |
| 37 | +eleventyConfig.addPassthroughCopy('robots.txt'); |
| 38 | + |
| 39 | + |
| 40 | +// format dates on SIGHTS and SOUNDS Articles |
| 41 | +const dateformat = require('./lib/filters/dateformat'); |
| 42 | +eleventyConfig.addFilter('datefriendly', dateformat.friendly); |
| 43 | +eleventyConfig.addFilter('dateymd', dateformat.ymd); |
| 44 | + |
| 45 | + |
| 46 | +// "return" in order to keep the previously entered configuration values |
| 47 | +// taken from: https://github.com/11ty/eleventy-base-blog/blob/master/.eleventy.js |
| 48 | +return { |
| 49 | + // Control which files Eleventy will process |
| 50 | + // e.g.: *.md, *.njk, *.html, *.liquid |
| 51 | + templateFormats: [ |
| 52 | + "md", |
| 53 | + "njk", |
| 54 | + "html", |
| 55 | + "liquid" |
| 56 | + ], |
| 57 | + |
| 58 | +// added |
| 59 | + passthroughFileCopy: true, |
| 60 | + |
| 61 | + // ----------------------------------------------------------------- |
| 62 | + // If your site deploys to a subdirectory, change `pathPrefix`. |
| 63 | + // Don’t worry about leading and trailing slashes, we normalize these. |
| 64 | + |
| 65 | + // If you don’t have a subdirectory, use "" or "/" (they do the same thing) |
| 66 | + // This is only used for link URLs (it does not affect your file structure) |
| 67 | + // Best paired with the `url` filter: https://www.11ty.dev/docs/filters/url/ |
| 68 | + |
| 69 | + // You can also pass this in on the command line using `--pathprefix` |
| 70 | + |
| 71 | + // Optional (default is shown) |
| 72 | + pathPrefix: "/", |
| 73 | + // ----------------------------------------------------------------- |
| 74 | + |
| 75 | + // Pre-process *.md files with: (default: `liquid`) |
| 76 | + markdownTemplateEngine: "njk", |
| 77 | + |
| 78 | + // Pre-process *.html files with: (default: `liquid`) |
| 79 | + htmlTemplateEngine: "njk", |
| 80 | + |
| 81 | + // Opt-out of pre-processing global data JSON files: (default: `liquid`) |
| 82 | + dataTemplateEngine: false, |
| 83 | + |
| 84 | + // These are all optional (defaults are shown): |
| 85 | + dir: { |
| 86 | + input: ".", |
| 87 | + includes: "_includes", |
| 88 | + data: "_data", |
| 89 | + output: "_site" |
| 90 | + } |
| 91 | +}; |
| 92 | +}; |
0 commit comments