Skip to content

Instantly share code, notes, and snippets.

@meyerweb
Last active March 6, 2021 19:54
Show Gist options
  • Save meyerweb/2a9d2fec59bff40dcb64dfcc498ddba7 to your computer and use it in GitHub Desktop.
Save meyerweb/2a9d2fec59bff40dcb64dfcc498ddba7 to your computer and use it in GitHub Desktop.
Eleventy problem
// !!!!! the next two functions do NOT break release.md !!!!!
eleventyConfig.addCollection("tagList", collection => {
const tagsSet = new Set();
collection.getAll().forEach(item => {
if (!item.data.tags) return;
item.data.tags
.filter(tag => !['post', 'all'].includes(tag))
.forEach(tag => tagsSet.add(tag));
});
return Array.from(tagsSet).sort();
});
eleventyConfig.addCollection("pkgList", collection => {
const pkgsSet = new Object;
collection.getAll().forEach(item => {
if (!item.data.package) return;
if (pkgsSet[item.data.package]) return;
pkgsSet[item.data.package] = {};
})
// for (val in pkgsSet) {
// pkgsSet[val] = {"pkg": val};
// };
return pkgsSet;
});
// !!!!! the next function BREAKS release.md !!!!!
eleventyConfig.addCollection("testList", collection => {
const testSet = new Object;
collection.getFilteredByTags("release").forEach(item => {
const data = item.data;
if (!data.package) return;
if (!testSet[data.package]) testSet[data.package] = new Object;
testSet[data.package] = {...testSet[data.package], ...item.data};
})
return testSet;
});
---
title: Releases
layout: page
pagination:
data: collections.release
size: 50
alias: posts
---
<section class="content-section bg-primary text-white small-section">
<div class="container text-center">
<div class="content-section-heading">
<h2>Release Announcements</h2>
</div>
</div>
</section>
<section class="content-section bg-light small-section">
<div class="container text-center">
<div class="row">
<div class="col-lg-10 mx-auto lead text-left">
<p> {{ collections.tagList }}
<p> {{ collections.pkgList }}
<p> {{ collections.testList }}
<h2>Stable</h2>
{%- for post in collections.stableReleaseNotes -%}
<h3 class="release-heading"><a href="{{ post.url | url }}">{{ post.data.title }}</a></h3>{{ post.date | dateString }}
| <strong>{{ post.data.package }}</strong>
| {{ post.data.version }}
| {{ post.data.tags }}
{%- endfor -%}
<h2>Unstable</h2>
{%- for post in collections.unstableReleaseNotes -%}
<h3 class="release-heading"><a href="{{ post.url | url }}">{{ post.data.title }}</a></h3>{{ post.date | dateString }}
| <strong>{{ post.data.package }}</strong>
| {{ post.data.version }}
| {{ post.data.tags }}
{%- endfor -%}
<h3>Latest Releases</h3>
{%- for release in collections.latestReleases -%}
<h4>{{ release[0] }}</h4>
{%- for type in release[1] -%}
<p>{{ type[1].version }} {{ type[0] }}</p>
{%- endfor -%}
{%- endfor -%}
<hr>
<p> {{ collections.packageList }}
<p> {{ collections.latestReleases }}
</div>
</div>
</div>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment