From fab17802822a73b3b0b676b315623ed29956071c Mon Sep 17 00:00:00 2001 From: Devin Haska <2636402+wonderfulfrog@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:32:19 -0800 Subject: [PATCH] feat: move games into their own section --- config/collections/index.js | 20 +++++ eleventy.config.js | 12 ++- src/_data/navigation.js | 2 +- src/_includes/layouts/game.html | 40 +++++++++ src/_includes/macros/media-grid.njk | 14 +++ src/_includes/macros/utils.njk | 15 ++-- src/catalogue/games/games.11tydata.js | 8 -- src/css/blocks/media-display.css | 17 ++++ src/css/blocks/media-grid.css | 85 +++++++++++++++++++ src/css/global/global-styles.css | 4 - src/css/utilities/flex.css | 4 + src/css/utilities/wrapper.css | 1 + .../games/2012-02-26-yoshis-island.md | 0 .../games/2015-03-01-majoras-mask-3d.md | 0 .../2015-04-18-mario-and-luigi-dream-team.md | 0 ...-21-donkey-kong-country-tropical-freeze.md | 0 ...4-26-professor-layton-vs-phoenix-wright.md | 0 .../games/2015-05-15-the-wonderful-101.md | 0 .../games/2015-12-02-fallout-4.md | 0 .../games/2016-03-16-persona-3-portable.md | 0 .../games/2016-08-22-shovel-knight.md | 0 .../games/2016-08-24-tomb-raider.md | 0 .../2016-12-31-assassins-creed-black-flag.md | 0 .../games/2017-01-02-doom-2016.md | 0 .../games/2017-01-29-hyper-light-drifter.md | 0 .../games/2017-02-26-vanquish.md | 0 .../games/2017-12-20-persona-5.md | 0 .../games/2018-04-10-axiom-verge.md | 0 ...2022-03-20-animal-crossing-new-horizons.md | 9 ++ .../games/2024-01-07-her-story.md | 0 ...024-01-19-middle-earth-shadow-of-mordor.md | 0 .../games/2024-01-27-citizen-sleeper.md | 2 + src/games/games.11tydata.js | 5 ++ src/pages/games/index.html | 21 +++++ src/pages/games/year.html | 19 +++++ 35 files changed, 257 insertions(+), 21 deletions(-) create mode 100644 src/_includes/layouts/game.html create mode 100644 src/_includes/macros/media-grid.njk delete mode 100644 src/catalogue/games/games.11tydata.js create mode 100644 src/css/blocks/media-display.css create mode 100644 src/css/blocks/media-grid.css rename src/{catalogue => }/games/2012-02-26-yoshis-island.md (100%) rename src/{catalogue => }/games/2015-03-01-majoras-mask-3d.md (100%) rename src/{catalogue => }/games/2015-04-18-mario-and-luigi-dream-team.md (100%) rename src/{catalogue => }/games/2015-04-21-donkey-kong-country-tropical-freeze.md (100%) rename src/{catalogue => }/games/2015-04-26-professor-layton-vs-phoenix-wright.md (100%) rename src/{catalogue => }/games/2015-05-15-the-wonderful-101.md (100%) rename src/{catalogue => }/games/2015-12-02-fallout-4.md (100%) rename src/{catalogue => }/games/2016-03-16-persona-3-portable.md (100%) rename src/{catalogue => }/games/2016-08-22-shovel-knight.md (100%) rename src/{catalogue => }/games/2016-08-24-tomb-raider.md (100%) rename src/{catalogue => }/games/2016-12-31-assassins-creed-black-flag.md (100%) rename src/{catalogue => }/games/2017-01-02-doom-2016.md (100%) rename src/{catalogue => }/games/2017-01-29-hyper-light-drifter.md (100%) rename src/{catalogue => }/games/2017-02-26-vanquish.md (100%) rename src/{catalogue => }/games/2017-12-20-persona-5.md (100%) rename src/{catalogue => }/games/2018-04-10-axiom-verge.md (100%) create mode 100644 src/games/2022-03-20-animal-crossing-new-horizons.md rename src/{catalogue => }/games/2024-01-07-her-story.md (100%) rename src/{catalogue => }/games/2024-01-19-middle-earth-shadow-of-mordor.md (100%) rename src/{catalogue => }/games/2024-01-27-citizen-sleeper.md (94%) create mode 100644 src/games/games.11tydata.js create mode 100644 src/pages/games/index.html create mode 100644 src/pages/games/year.html 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 %} -