-
Notifications
You must be signed in to change notification settings - Fork 1
A few random tweaks #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
|
|
||
| module.exports = function (eleventyConfig) { | ||
|
|
||
| // SIGHTS - custom collections | ||
| const nowsights = new Date(); | ||
| const sightslivePosts = (post) => post.date <= nowsights; | ||
|
|
@@ -10,6 +8,19 @@ module.exports = function (eleventyConfig) { | |
| ].reverse(); | ||
| }); | ||
|
|
||
| eleventyConfig.addFilter("head", (arr = [], idx = 0) => { | ||
| if (idx < 0) { | ||
| return arr.slice(idx); | ||
| } | ||
| return arr.slice(0, idx); | ||
| }); | ||
|
|
||
| eleventyConfig.addFilter("tagsList", (arr = []) => { | ||
| const tagsSet = new Set(); | ||
| arr.forEach((item) => item.data.tags?.forEach((tag) => tagsSet.add(tag))); | ||
| return [...tagsSet].sort((b, a) => b.localeCompare(a)); | ||
| }); | ||
|
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basically the same logic as your custom collection, except for as a filter; so now you can pass a custom collection. |
||
|
|
||
| // SOUNDS - custom collections | ||
| const nowsounds = new Date(); | ||
| const soundslivePosts = (post) => post.date <= nowsounds; | ||
|
|
@@ -21,72 +32,64 @@ module.exports = function (eleventyConfig) { | |
|
|
||
| // generate a list of all tags collections | ||
| // with alphabetical sorting - had to invert to "b, a" because it was sorting upside down | ||
| eleventyConfig.addCollection('tagsList', (collectionApi) => { | ||
| const tagsSet = new Set() | ||
| collectionApi.getAll().forEach((item) => { | ||
| if (!item.data.tags) return | ||
| item.data.tags.forEach((tag) => tagsSet.add(tag)) | ||
| }) | ||
| return [...tagsSet].sort((b, a) => b.localeCompare(a)) | ||
| }); | ||
|
|
||
|
|
||
| // https://www.11ty.dev/docs/copy/#manual-passthrough-file-copy-(faster) | ||
| eleventyConfig.addPassthroughCopy('assets'); | ||
| eleventyConfig.addPassthroughCopy('sitemap.xml'); | ||
| eleventyConfig.addPassthroughCopy('robots.txt'); | ||
|
|
||
|
|
||
| // format dates on SIGHTS and SOUNDS Articles | ||
| const dateformat = require('./lib/filters/dateformat'); | ||
| eleventyConfig.addFilter('datefriendly', dateformat.friendly); | ||
| eleventyConfig.addFilter('dateymd', dateformat.ymd); | ||
|
|
||
|
|
||
| // "return" in order to keep the previously entered configuration values | ||
| // taken from: https://github.com/11ty/eleventy-base-blog/blob/master/.eleventy.js | ||
| return { | ||
| // Control which files Eleventy will process | ||
| // e.g.: *.md, *.njk, *.html, *.liquid | ||
| templateFormats: [ | ||
| "md", | ||
| "njk", | ||
| "html", | ||
| "liquid" | ||
| ], | ||
|
|
||
| // added | ||
| passthroughFileCopy: true, | ||
|
|
||
| // ----------------------------------------------------------------- | ||
| // If your site deploys to a subdirectory, change `pathPrefix`. | ||
| // Don’t worry about leading and trailing slashes, we normalize these. | ||
|
|
||
| // If you don’t have a subdirectory, use "" or "/" (they do the same thing) | ||
| // This is only used for link URLs (it does not affect your file structure) | ||
| // Best paired with the `url` filter: https://www.11ty.dev/docs/filters/url/ | ||
|
|
||
| // You can also pass this in on the command line using `--pathprefix` | ||
|
|
||
| // Optional (default is shown) | ||
| pathPrefix: "/", | ||
| // ----------------------------------------------------------------- | ||
|
|
||
| // Pre-process *.md files with: (default: `liquid`) | ||
| markdownTemplateEngine: "njk", | ||
|
|
||
| // Pre-process *.html files with: (default: `liquid`) | ||
| htmlTemplateEngine: "njk", | ||
|
|
||
| // Opt-out of pre-processing global data JSON files: (default: `liquid`) | ||
| dataTemplateEngine: false, | ||
|
|
||
| // These are all optional (defaults are shown): | ||
| dir: { | ||
| input: ".", | ||
| includes: "_includes", | ||
| data: "_data", | ||
| output: "_site" | ||
| } | ||
| }; | ||
| // eleventyConfig.addCollection('tagsList', (collectionApi) => { | ||
| // const tagsSet = new Set() | ||
| // collectionApi.getAll().forEach((item) => { | ||
| // if (!item.data.tags) return | ||
| // item.data.tags.forEach((tag) => tagsSet.add(tag)) | ||
| // }) | ||
| // return [...tagsSet].sort((b, a) => b.localeCompare(a)) | ||
| // }); | ||
|
|
||
| // https://www.11ty.dev/docs/copy/#manual-passthrough-file-copy-(faster) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can ignore all these changes below. I think I ran |
||
| eleventyConfig.addPassthroughCopy("assets"); | ||
| eleventyConfig.addPassthroughCopy("sitemap.xml"); | ||
| eleventyConfig.addPassthroughCopy("robots.txt"); | ||
|
|
||
| // format dates on SIGHTS and SOUNDS Articles | ||
| const dateformat = require("./lib/filters/dateformat"); | ||
| eleventyConfig.addFilter("datefriendly", dateformat.friendly); | ||
| eleventyConfig.addFilter("dateymd", dateformat.ymd); | ||
|
|
||
| // "return" in order to keep the previously entered configuration values | ||
| // taken from: https://github.com/11ty/eleventy-base-blog/blob/master/.eleventy.js | ||
| return { | ||
| // Control which files Eleventy will process | ||
| // e.g.: *.md, *.njk, *.html, *.liquid | ||
| templateFormats: ["md", "njk", "html", "liquid"], | ||
|
|
||
| // added | ||
| passthroughFileCopy: true, | ||
|
|
||
| // ----------------------------------------------------------------- | ||
| // If your site deploys to a subdirectory, change `pathPrefix`. | ||
| // Don’t worry about leading and trailing slashes, we normalize these. | ||
|
|
||
| // If you don’t have a subdirectory, use "" or "/" (they do the same thing) | ||
| // This is only used for link URLs (it does not affect your file structure) | ||
| // Best paired with the `url` filter: https://www.11ty.dev/docs/filters/url/ | ||
|
|
||
| // You can also pass this in on the command line using `--pathprefix` | ||
|
|
||
| // Optional (default is shown) | ||
| pathPrefix: "/", | ||
| // ----------------------------------------------------------------- | ||
|
|
||
| // Pre-process *.md files with: (default: `liquid`) | ||
| markdownTemplateEngine: "njk", | ||
|
|
||
| // Pre-process *.html files with: (default: `liquid`) | ||
| htmlTemplateEngine: "njk", | ||
|
|
||
| // Opt-out of pre-processing global data JSON files: (default: `liquid`) | ||
| dataTemplateEngine: false, | ||
|
|
||
| // These are all optional (defaults are shown): | ||
| dir: { | ||
| input: ".", | ||
| includes: "_includes", | ||
| data: "_data", | ||
| output: "_site", | ||
| }, | ||
| }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,7 @@ local: en | |
|
|
||
| <h1>HOMEPAGE</h1> | ||
|
|
||
| <!-- | ||
|
|
||
| TO DO | ||
| {# TO DO | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used a Nunjucks comment so that it wouldnt try compiling the code below (see previous note about missing |
||
|
|
||
| Here I want to FILTER RECENT POSTS | ||
| respectively for categories SIGHTS + SOUNDS with the latest 4 posts for each category | ||
|
|
@@ -42,6 +40,5 @@ as explained here: https://github.com/11ty/eleventy/issues/503 ( pdkaizer commen | |
| pagination: | ||
| data: collections... // the problem here is that I can specify only 1 collection and I have two of them to output on this page: how to solve this? | ||
| size: 4 | ||
| reverse: true | ||
| reverse: true #} | ||
|
|
||
| --> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ pagination: | |
| - sounds | ||
| - tagsList | ||
| addAllPagesToCollections: true | ||
| permalink: /sights/tags/{{ tag | slug }}/ | ||
| permalink: "/sights/tags/{{ tag | slug }}/" | ||
| --- | ||
| <!-- this should be tag archive for SIGHTS category only --> | ||
| <!-- This will create a page for every tag --> | ||
|
|
@@ -33,7 +33,7 @@ permalink: /sights/tags/{{ tag | slug }}/ | |
| <p> | ||
| <!-- PROBLEM --> | ||
| <!-- outputs tags. Should be all tags for collection.sights only, but outputs also all collections.sounds tags - I don't want this to happen and I have to find a solution --> | ||
| {% for tag in collections.tagsList %} | ||
| {% for tag in collections.sights | tagsList %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So instead of using |
||
| <a href="/sights/tags/{{ tag | slug }}" class="tags">{{tag}}</a> | ||
| {% endfor %} | ||
| </p> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ pagination: | |
| - sounds | ||
| - tagsList | ||
| addAllPagesToCollections: true | ||
| permalink: /sounds/tags/{{ tag | slug }}/ | ||
| permalink: "/sounds/tags/{{ tag | slug }}/" | ||
| --- | ||
| <!-- this should be tag archive for SOUNDS category only --> | ||
| <!-- This will create a page for every tag --> | ||
|
|
@@ -33,7 +33,7 @@ permalink: /sounds/tags/{{ tag | slug }}/ | |
| <p> | ||
| <!-- PROBLEM --> | ||
| <!-- outputs tags. Should be all tags for collection.sounds only, but outputs also all collections.sights tags - I don't want this to happen and I have to find a solution --> | ||
| {% for tag in collections.tagsList %} | ||
| {% for tag in collections.sounds | tagsList %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above re "collections.sights" and custom |
||
| <a href="/sounds/tags/{{ tag | slug }}" class="tags">{{tag}}</a> | ||
| {% endfor %} | ||
| </p> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably ignore this. I think it was from the index.njk and was throwing errors saying there wasn't a "head" filter, so I took a random guess. But then ended up using Nunjucks comments to comment out those code blocks anyways.