-
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?
Conversation
| eleventyConfig.addFilter("head", (arr = [], idx = 0) => { | ||
| if (idx < 0) { | ||
| return arr.slice(idx); | ||
| } | ||
| return arr.slice(0, idx); | ||
| }); |
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.
| 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)); | ||
| }); |
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.
This is basically the same logic as your custom collection, except for as a filter; so now you can pass a custom collection.
| // 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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore all these changes below. I think I ran prettier against the input/output and it probably fixed the indenting here.
| <!-- | ||
| TO DO | ||
| {# TO DO |
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.
Used a Nunjucks comment so that it wouldnt try compiling the code below (see previous note about missing head filter).
| <!-- 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 comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of using collections.tagsList (which uses .getAll() and getting sights+sounds) I can use the new custom tagsList filter to just generate a tag list for the "sights" collection specifically.
| <!-- 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 comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above re "collections.sights" and custom tagsList filter.
No description provided.