diff --git a/config/filters/index.js b/config/filters/index.js index 9b34a68..b6deaaf 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -4,6 +4,7 @@ const advancedFormat = require("dayjs/plugin/advancedFormat"); const postcss = require("postcss"); const cssnano = require("cssnano"); +const pluralizeBase = require("pluralize"); const keys = Object.keys; const values = Object.values; @@ -36,10 +37,6 @@ const organizeByDate = (collection) => { return collectionByDate; }; -const filterByCategory = (collection, category) => { - return collection.filter((item) => item.data.categories.includes(category)); -}; - const allTags = (collection, ignore = []) => { const tagSet = new Set(collection.flatMap((item) => item.data.tags)); @@ -77,15 +74,19 @@ const filter = (collection, filters = []) => { return collection.filter((item) => !filters.includes(item)); }; +const pluralize = (string, count = 0) => { + return pluralizeBase(string, count); +}; + module.exports = { + allTagCounts, + allTags, entries, - filterByCategory, + filter, formatDate, keys, minifyCss, organizeByDate, + pluralize, values, - allTags, - allTagCounts, - filter, }; diff --git a/eleventy.config.js b/eleventy.config.js index c2603b7..0d55706 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -12,6 +12,7 @@ const { keys, allTagCounts, filter, + pluralize, } = require("./config/filters/index.js"); const markdown = require("./config/plugins/markdown.js"); const imageShortcode = require("./config/shortcodes/image.js"); @@ -37,6 +38,7 @@ module.exports = (eleventyConfig) => { eleventyConfig.addFilter("minifyCss", minifyCss); eleventyConfig.addFilter("organizeByDate", organizeByDate); eleventyConfig.addFilter("values", values); + eleventyConfig.addFilter("pluralize", pluralize); // --------------------- Passthrough File Copy ----------------------- ["src/assets/fonts/", "src/assets/images"].forEach((path) => diff --git a/package-lock.json b/package-lock.json index ade8381..74f4625 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "markdown-it-anchor": "^8.6.7", "markdown-it-footnote": "^4.0.0", "markdown-it-prism": "^2.3.0", + "pluralize": "^8.0.0", "postcss": "^8.4.33", "postcss-import": "^16.0.0", "postcss-import-ext-glob": "^2.1.1", @@ -3498,6 +3499,15 @@ "semver-compare": "^1.0.0" } }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/postcss": { "version": "8.4.35", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", @@ -7696,6 +7706,12 @@ "semver-compare": "^1.0.0" } }, + "pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true + }, "postcss": { "version": "8.4.35", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", diff --git a/package.json b/package.json index 05e7ba5..db7f0d5 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "markdown-it-anchor": "^8.6.7", "markdown-it-footnote": "^4.0.0", "markdown-it-prism": "^2.3.0", + "pluralize": "^8.0.0", "postcss": "^8.4.33", "postcss-import": "^16.0.0", "postcss-import-ext-glob": "^2.1.1", diff --git a/src/_includes/partials/archive.html b/src/_includes/partials/archive.html index 41c2c30..8fd741f 100644 --- a/src/_includes/partials/archive.html +++ b/src/_includes/partials/archive.html @@ -3,7 +3,7 @@
{% for year in years %} {% set itemsInYear = itemsByYear[year] %} -
+

{{ year }}

diff --git a/src/_includes/partials/catalogue.html b/src/_includes/partials/catalogue.html index ddf76c2..6bde1ab 100644 --- a/src/_includes/partials/catalogue.html +++ b/src/_includes/partials/catalogue.html @@ -3,16 +3,16 @@
{% for year in years %} {% set itemsInYear = itemsByYear[year] %} -
+

{{ year }}

{% for item in itemsInYear %} {% set type = item.data.tags[1] %} -
+
{{ item.data.title }} -
-

{{ type }}

+
+

{{ type }}

{{ item.date | formatDate("MM/DD") }}

{% endfor %} diff --git a/src/assets/css/blocks/catalogue.css b/src/assets/css/blocks/catalogue.css index 05fcd30..65463eb 100644 --- a/src/assets/css/blocks/catalogue.css +++ b/src/assets/css/blocks/catalogue.css @@ -1,3 +1,8 @@ .catalogue .meta img { inline-size: 10rem; } + +.catalogue-type { + font-size: 0.8rem; + border-radius: 0.5rem; +} diff --git a/src/content/catalogue/books/books.json b/src/content/catalogue/books/books.json index a7f6ce7..5f32a2e 100644 --- a/src/content/catalogue/books/books.json +++ b/src/content/catalogue/books/books.json @@ -1,5 +1,5 @@ { "layout": "catalogue", "tags": "book", - "permalink": "books/{{ page.fileSlug }}/index.html" + "permalink": "catalogue/books/{{ page.fileSlug }}/index.html" } diff --git a/src/content/catalogue/catalogueType.html b/src/content/catalogue/catalogueType.html new file mode 100644 index 0000000..19ac5a4 --- /dev/null +++ b/src/content/catalogue/catalogueType.html @@ -0,0 +1,26 @@ +--- +layout: base +pagination: + data: collections.catalogueByType + size: 1 + alias: type + filter: + - catalogue +eleventyExcludeFromCollections: true +permalink: /catalogue/{{ type | pluralize | slugify }}/index.html +eleventyComputed: + title: Catalogue - {{ type | pluralize | capitalize }} +--- + +

{{ type | pluralize | capitalize }}

+{% set catalogueTypes = collections.catalogueByType | keys %} + +{% set items = collections.catalogueByType[ type ] %} +{% include "partials/catalogue.html" %} diff --git a/src/content/catalogue/comics/comics.json b/src/content/catalogue/comics/comics.json index 2a8ab19..fcfe7a0 100644 --- a/src/content/catalogue/comics/comics.json +++ b/src/content/catalogue/comics/comics.json @@ -1,5 +1,5 @@ { "layout": "catalogue", "tags": "comic", - "permalink": "comics/{{ page.fileSlug }}/index.html" + "permalink": "catalogue/comics/{{ page.fileSlug }}/index.html" } diff --git a/src/content/catalogue/games/games.json b/src/content/catalogue/games/games.json index 3fdb03c..04a01c0 100644 --- a/src/content/catalogue/games/games.json +++ b/src/content/catalogue/games/games.json @@ -1,5 +1,5 @@ { "layout": "catalogue", "tags": "game", - "permalink": "games/{{ page.fileSlug }}/index.html" + "permalink": "catalogue/games/{{ page.fileSlug }}/index.html" } diff --git a/src/content/catalogue/podcasts/podcasts.json b/src/content/catalogue/podcasts/podcasts.json index 39f08de..b12f18c 100644 --- a/src/content/catalogue/podcasts/podcasts.json +++ b/src/content/catalogue/podcasts/podcasts.json @@ -1,5 +1,5 @@ { "layout": "catalogue", "tags": "podcast", - "permalink": "podcasts/{{ page.fileSlug }}/index.html" + "permalink": "catalogue/podcasts/{{ page.fileSlug }}/index.html" } diff --git a/src/content/pages/catalogue.html b/src/content/pages/catalogue.html index d54a83e..b64ee5a 100644 --- a/src/content/pages/catalogue.html +++ b/src/content/pages/catalogue.html @@ -6,4 +6,13 @@ title: Catalogue

Catalogue

{% set items = collections.catalogue | reverse %} +{% set catalogueTypes = collections.catalogueByType | keys %} + {% include "partials/catalogue.html" %}