From: Cameron Otsuka Date: Sun, 22 Dec 2024 08:00:58 +0000 (-0800) Subject: add activities metacollection and reviews collection X-Git-Tag: v1.0.0~74 X-Git-Url: https://git.otsuka.systems/?a=commitdiff_plain;h=f4ba3d7dcd61aa3a17b96c364b4bb9c767c2cb7d;p=cotsuka.github.io add activities metacollection and reviews collection --- diff --git a/_includes/components/activitylist.njk b/_includes/components/activitylist.njk new file mode 100644 index 0000000..b92a70b --- /dev/null +++ b/_includes/components/activitylist.njk @@ -0,0 +1,19 @@ +
+{% if maxPosts %} + {% set numPosts = collections.activities | length | min(maxPosts) %} + {% set activitieslist = collections.activities | reverse | head(numPosts) %} +{% else %} + {% set activitieslist = collections.activities | reverse %} +{% endif %} +{%- for item in activitieslist %} +
{{ item.data.title }}
+
+ {% if "articles" in item.data.tags %} + article + {% elseif "reviews" in item.data.tags %} + review + {% endif %} + {{ item.data.description }} +
+{%- endfor %} +
\ No newline at end of file diff --git a/_includes/components/reviewslist.njk b/_includes/components/reviewslist.njk new file mode 100644 index 0000000..85b52ab --- /dev/null +++ b/_includes/components/reviewslist.njk @@ -0,0 +1,21 @@ +
+{% if maxPosts %} + {% set numPosts = collections.reviews | length | min(maxPosts) %} + {% set reviewslist = collections.reviews | reverse | head(numPosts) %} +{% else %} + {% set reviewslist = collections.reviews | reverse %} +{% endif %} +{%- for review in reviewslist %} +
{{ review.data.title }}
+
+ {% if "movie" in review.data.tags %} + movie + {% elseif "music" in review.data.tags %} + music + {% elseif "show" in review.data.tags %} + show + {% endif %} + {{ review.data.description }} +
+{%- endfor %} +
\ No newline at end of file diff --git a/_includes/css/style.css b/_includes/css/style.css index 267b5ec..816a6d8 100644 --- a/_includes/css/style.css +++ b/_includes/css/style.css @@ -13,12 +13,23 @@ body { font-size: 1rem; } nav { + margin-bottom: 1rem; +} +nav > h1 { font-size: 2rem; font-weight: bold; } -nav > a { +nav > h1 > a { text-decoration: none; } +nav > menu { + margin-inline-start: 0; + padding-inline-start: 0; +} +nav > menu > li { + display: inline; + padding-right: 1rem; +} details { margin-bottom: 1rem; } @@ -67,6 +78,9 @@ th, td { object { width: 100%; } +hr { + margin-bottom: 1rem; +} footer { text-align: center; font-style: italic; @@ -78,4 +92,7 @@ footer > address > menu { footer > address > menu > li { display: inline; padding-right: 1rem; +} +.collectiontag { + font-variant: small-caps; } \ No newline at end of file diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index 3ec226e..289262a 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -58,9 +58,14 @@
+
{{ content | safe }}
diff --git a/_includes/layouts/home.njk b/_includes/layouts/home.njk index 7ae154e..62beefd 100644 --- a/_includes/layouts/home.njk +++ b/_includes/layouts/home.njk @@ -8,8 +8,8 @@ maxPosts: 5
-

Articles

- {%- include "components/articleslist.njk" %} +

Latest Activity

+ {%- include "components/activitylist.njk" %}
diff --git a/_includes/layouts/review.njk b/_includes/layouts/review.njk new file mode 100644 index 0000000..d9973f1 --- /dev/null +++ b/_includes/layouts/review.njk @@ -0,0 +1,30 @@ +--- +layout: layouts/base.njk +--- + +

{{ title }}

+ +
+ Metadata +
    +
  • Published:
  • +
  • Description: {{ description }}
  • +
  • Tags: {{ tags | reject("equalto", "articles") | sort | join(", ") }}
  • + {% if posse %} +
  • + Also Posted To: + {% for item in posse %} + {% if item["letterboxd"] %} + Letterboxd + {% elseif item["goodreads"] %} + Goodreads + {% endif %} + {% endfor %} +
  • + {% endif %} +
+
+ +
+ {{ content | safe }} +
diff --git a/content/reviews.njk b/content/reviews.njk new file mode 100644 index 0000000..9d50f74 --- /dev/null +++ b/content/reviews.njk @@ -0,0 +1,7 @@ +--- +layout: layouts/base.njk +--- + +

Reviews

+ +{% include "components/reviewslist.njk" %} diff --git a/content/reviews/reviews.json b/content/reviews/reviews.json new file mode 100644 index 0000000..72ea2b8 --- /dev/null +++ b/content/reviews/reviews.json @@ -0,0 +1,5 @@ +{ + "tags": ["reviews"], + "layout": "layouts/review.njk", + "permalink": "reviews/{{ date | htmlDateString }}-{{ title | slugify }}/" +} \ No newline at end of file diff --git a/eleventy.config.js b/eleventy.config.js index a264a30..1429132 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -22,6 +22,17 @@ function isFullUrl(url) { } module.exports = function (eleventyConfig) { + eleventyConfig.addCollection("activities", function(collectionApi) { + let collectionSubset = [ + ...collectionApi.getFilteredByTag("articles"), + ...collectionApi.getFilteredByTag("reviews"), + ]; + let sortedSubset = collectionSubset.sort(function(a, b) { + // maintain sort order when working with default collections objects + return a.date - b.date; + }); + return sortedSubset; + }); eleventyConfig.addFilter("cssmin", function (code) { return new cleanCSS({}).minify(code).styles; });