Skip to content

Commit

Permalink
Always use the latest version, by looking at the latest version released
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Nov 27, 2024
1 parent 9843cee commit b03896c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 37 deletions.
73 changes: 40 additions & 33 deletions eleventy.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
const pluginRss = require("@11ty/eleventy-plugin-rss");
const markdownIt = require("markdown-it");

module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/favicon.ico");
eleventyConfig.addPlugin(pluginRss);

eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
});

eleventyConfig.addFilter("md", function (content = "") {
return markdownIt({ html: true }).render(content);
});

eleventyConfig.addFilter("dateIso", date => {
return date.toISOString();
});

eleventyConfig.addFilter("dateReadable", date => {
return date.toDateString();
});

eleventyConfig.addCollection("posts", function(collection) {
return collection.getFilteredByGlob("src/news/*.md");
});

return {
dir: {
input: "src",
output: "dist",
includes: "_layouts"
}
};
}
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/favicon.ico");
eleventyConfig.addPlugin(pluginRss);

eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
});

eleventyConfig.addFilter("md", function (content = "") {
return markdownIt({ html: true }).render(content);
});

eleventyConfig.addFilter("dateIso", (date) => {
return date.toISOString();
});

eleventyConfig.addFilter("dateReadable", (date) => {
return date.toDateString();
});

eleventyConfig.addCollection("posts", function (collection) {
return collection.getFilteredByGlob("src/news/*.md");
});

eleventyConfig.addFilter("getLatestVersion", function (collection) {
// Find the latest known version from the collection
return collection?.reduce((latest, item) => {
return !latest || item.data.version > latest ? item.data.version : latest;
}, null);
});

return {
dir: {
input: "src",
output: "dist",
includes: "_layouts",
},
};
};
3 changes: 1 addition & 2 deletions src/_data/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"name": "Dangerzone development team",
"email": "[email protected]"
},
"github_repo": "https://github.com/freedomofpress/dangerzone",
"version": "0.8.0"
"github_repo": "https://github.com/freedomofpress/dangerzone"
}
3 changes: 3 additions & 0 deletions src/_layouts/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ layout: base
<div class="post-time"><time datetime="{{ date | dateIso }}">{{ date | dateReadable }}</time></div>
{{ content | safe }}
</div>
{% if version %}
{% include "../_includes/downloads.njk" %}
{% endif %}
</article>
6 changes: 4 additions & 2 deletions src/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ layout: base.njk
</div>
</section>

{% set version = site.version %}
{% include "./_includes/downloads.njk" %}
{% set version = collections.posts | getLatestVersion %}
{% if version %}
{% include "./_includes/downloads.njk" %}
{% endif %}

<section class="wrapper" id="news">
<h2>How It Works</h2>
Expand Down

0 comments on commit b03896c

Please sign in to comment.