diff --git a/config/collections/index.js b/config/collections/index.js index 892159b..2f0e115 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -1,3 +1,5 @@ +import dayjs from "dayjs"; + export const postsByTag = (collection) => { const posts = collection.getFilteredByTag("post"); @@ -13,6 +15,24 @@ export const postsByTag = (collection) => { return postsByTag; }; +export const gamesByYear = (collection) => { + const allGames = collection.getFilteredByTag("game"); + const gamesByYear = {}; + + allGames.forEach((game) => { + const date = new dayjs(game.date); + const year = date.year(); + + if (!gamesByYear[year]) { + gamesByYear[year] = { value: year, data: [game] }; + } else { + gamesByYear[year].data.push(game); + } + }); + + return gamesByYear; +}; + export const catalogueByType = (collection) => { const allItems = collection.getFilteredByTag("catalogue"); diff --git a/eleventy.config.js b/eleventy.config.js index b7c885e..11ff310 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,8 +1,13 @@ +import util from "util"; import pluginRss from "@11ty/eleventy-plugin-rss"; import pluginNoRobots from "eleventy-plugin-no-robots"; import { eleventyImageTransformPlugin } from "@11ty/eleventy-img"; -import { catalogueByType, postsByTag } from "./config/collections/index.js"; +import { + catalogueByType, + postsByTag, + gamesByYear, +} from "./config/collections/index.js"; import { dir } from "./config/constants.js"; import { @@ -32,6 +37,7 @@ export default function (eleventyConfig) { eleventyConfig.addPlugin(pluginNoRobots); // --------------------- Custom Collections ----------------------- + eleventyConfig.addCollection("gamesByYear", gamesByYear); eleventyConfig.addCollection("catalogueByType", catalogueByType); eleventyConfig.addCollection("postsByTag", postsByTag); @@ -81,6 +87,10 @@ export default function (eleventyConfig) { // --------------------- Shortcodes ----------------------- eleventyConfig.addShortcode("youtube", liteYoutube); + eleventyConfig.addFilter("console", function (value) { + return util.inspect(value); + }); + return { // Optional (default is set): If your site deploys to a subdirectory, change `pathPrefix`, for example with with GitHub pages pathPrefix: "/", diff --git a/src/_data/navigation.js b/src/_data/navigation.js index 8cc8f19..f8a5b29 100644 --- a/src/_data/navigation.js +++ b/src/_data/navigation.js @@ -12,7 +12,7 @@ export default { }, { text: "Games", - url: "/catalogue/games", + url: "/games", icon: "game-controller", }, { diff --git a/src/_includes/layouts/game.html b/src/_includes/layouts/game.html new file mode 100644 index 0000000..ab2106f --- /dev/null +++ b/src/_includes/layouts/game.html @@ -0,0 +1,40 @@ +--- +layout: "layouts/base" +--- + +{% from "macros/date.njk" import format %} +{% from "macros/utils.njk" import stars %} +
+
+ +
+
+
+

{{ title }}

+ {{ platform }} +
+ {% if subtitle %}

{{ subtitle }}

{% endif %} + {{ format(page.date) }} + {% if rating %}{{ stars(rating) }}{% endif %} + +
+
+
+ {{ content | safe }} +
diff --git a/src/_includes/macros/media-grid.njk b/src/_includes/macros/media-grid.njk new file mode 100644 index 0000000..ffc5816 --- /dev/null +++ b/src/_includes/macros/media-grid.njk @@ -0,0 +1,14 @@ +{% macro grid(data, shape = "vertical") %} + +{% endmacro %} diff --git a/src/_includes/macros/utils.njk b/src/_includes/macros/utils.njk index 4a40aee..8caa05a 100644 --- a/src/_includes/macros/utils.njk +++ b/src/_includes/macros/utils.njk @@ -1,12 +1,13 @@ {% macro stars(number) %} {% set filledStars = number %} {% set emptyStars = 5 - number %} -