diff --git a/config/filters/index.js b/config/filters/index.js
index 46c981f..95df1d2 100644
--- a/config/filters/index.js
+++ b/config/filters/index.js
@@ -5,6 +5,7 @@ const advancedFormat = require("dayjs/plugin/advancedFormat");
const postcss = require("postcss");
const cssnano = require("cssnano");
+const keys = Object.keys;
const values = Object.values;
const entries = Object.entries;
@@ -24,19 +25,12 @@ const organizeByDate = (collection) => {
collection.forEach((item) => {
const year = formatDate(item.date, "YYYY");
- const month = formatDate(item.date, "MMMM");
if (!collectionByDate[year]) {
- return (collectionByDate[year] = {
- [month]: [item],
- });
+ return (collectionByDate[year] = [item]);
}
- if (!collectionByDate[year][month]) {
- return (collectionByDate[year][month] = [item]);
- }
-
- collectionByDate[year][month].push(item);
+ collectionByDate[year].push(item);
});
return collectionByDate;
@@ -45,6 +39,7 @@ const organizeByDate = (collection) => {
module.exports = {
entries,
formatDate,
+ keys,
minifyCss,
organizeByDate,
values,
diff --git a/eleventy.config.js b/eleventy.config.js
index 7f716b5..a2daa55 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -11,6 +11,7 @@ const {
minifyCss,
values,
organizeByDate,
+ keys,
} = require("./config/filters/index.js");
const markdown = require("./config/plugins/markdown.js");
const imageShortcode = require("./config/shortcodes/image.js");
@@ -31,6 +32,7 @@ module.exports = (eleventyConfig) => {
// --------------------- Custom Filters -----------------------
eleventyConfig.addFilter("entries", entries);
eleventyConfig.addFilter("formatDate", formatDate);
+ eleventyConfig.addFilter("keys", keys);
eleventyConfig.addFilter("minifyCss", minifyCss);
eleventyConfig.addFilter("organizeByDate", organizeByDate);
eleventyConfig.addFilter("values", values);
diff --git a/src/_includes/partials/archive.html b/src/_includes/partials/archive.html
new file mode 100644
index 0000000..dd3546d
--- /dev/null
+++ b/src/_includes/partials/archive.html
@@ -0,0 +1,17 @@
+{% set itemsByYear = items | organizeByDate %}
+{% set years = itemsByYear | keys | sort("desc") %}
+{{ year }}
+ {{ year }}
-
View all tags
-{% include "partials/posts.html" %} +{% set items = collections.posts %} +{% include "partials/archive.html" %}