]> git.otsuka.systems Git - cotsuka.github.io/commitdiff
merge into single post layout, add startswith filter, fix article list tags
authorCameron Otsuka <cameron@otsuka.haus>
Thu, 20 Mar 2025 23:30:03 +0000 (16:30 -0700)
committerCameron Otsuka <cameron@otsuka.haus>
Thu, 20 Mar 2025 23:30:03 +0000 (16:30 -0700)
_includes/components/activitylist.njk
_includes/layouts/article.njk [deleted file]
_includes/layouts/link.njk [deleted file]
_includes/layouts/post.njk [new file with mode: 0644]
_includes/layouts/review.njk [deleted file]
content/articles/articles.json
content/links/links.json
content/reviews/reviews.json
eleventy.config.js

index ef74ab02f349ff7f543fc0a81b170aa8557e73d4..51383cdb1cb2a0cdcf0146058d4c116293e634f1 100644 (file)
@@ -16,7 +16,9 @@
     <dt><a href="{{ item.url }}">{{ item.data.title }}</a></dt>
     <dd>
         {% set tag = false %}
-        {% if page.filePathStem === "/links" %}
+        {% if page.filePathStem === "/articles" %}
+            {% set tag = "" %}
+        {% elseif page.filePathStem === "/links" %}
             {% if "livestream" in item.data.tags %}
                 {% set tag = "livestream" %}
             {% elseif "podcast" in item.data.tags %}
diff --git a/_includes/layouts/article.njk b/_includes/layouts/article.njk
deleted file mode 100644 (file)
index 9c0c02f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
----
-layout: layouts/base.njk
----
-
-<h1>{{ title }}</h1>
-
-<details>
-       <summary>Metadata</summary>
-       <ul>
-               <li>Published: <time datetime="{{ page.date | htmlDateString }}">{{ page.date | htmlDateString }}</time></li>
-               <li>Description: {{ description }}</li>
-               <li>Tags: {{ tags | reject("equalto", "articles") | sort | join(", ") }}</li>
-               {%- if posse %}
-                       {%- include "components/posse.njk" %}
-               {%- endif %}
-       </ul>
-</details>
-
-<article>
-       {{ content | safe }}
-</article>
diff --git a/_includes/layouts/link.njk b/_includes/layouts/link.njk
deleted file mode 100644 (file)
index 388c0ae..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
----
-layout: layouts/base.njk
----
-
-<h1><a href="{{ href }}">{{ title }}</a></h1>
-
-<details>
-       <summary>Metadata</summary>
-       <ul>
-               <li>Published: <time datetime="{{ page.date | htmlDateString }}">{{ page.date | htmlDateString }}</time></li>
-               <li>Description: {{ description }}</li>
-               <li>Tags: {{ tags | reject("equalto", "links") | sort | join(", ") }}</li>
-               {%- if posse %}
-                       {%- include "components/posse.njk" %}
-               {%- endif %}
-       </ul>
-</details>
-
-<article>
-       {{ content | safe }}
-</article>
diff --git a/_includes/layouts/post.njk b/_includes/layouts/post.njk
new file mode 100644 (file)
index 0000000..b963f67
--- /dev/null
@@ -0,0 +1,45 @@
+---
+layout: layouts/base.njk
+---
+
+<h1>
+       {% if page.filePathStem | startsWith("/links") %}
+               <a href="{{ href }}">{{ title }}</a>
+       {% else %}
+               {{ title }}
+       {% endif %}
+</h1>
+
+<details>
+       <summary>Metadata</summary>
+       <ul>
+               <li>Published: <time datetime="{{ page.date | htmlDateString }}">{{ page.date | htmlDateString }}</time></li>
+               <li>
+                       {% if page.filePathStem | startsWith("/reviews") %}
+                               Rating:
+                       {% else %}
+                               Description:
+                       {% endif %}
+                       {{ description }}
+               </li>
+               <li>
+                       Tags:
+                       {% if page.filePathStem | startsWith("/articles") %}
+                               {{ tags | reject("equalto", "articles") | sort | join(", ") }}
+                       {% elseif page.filePathStem | startsWith("/links") %}
+                               {{ tags | reject("equalto", "links") | sort | join(", ") }}
+                       {% elseif page.filePathStem | startsWith("/reviews") %}
+                               {{ tags | reject("equalto", "reviews") | sort | join(", ") }}
+                       {% else %}
+                               {{ tags | sort | join(", ") }}
+                       {% endif %}
+               </li>
+               {%- if posse %}
+                       {%- include "components/posse.njk" %}
+               {%- endif %}
+       </ul>
+</details>
+
+<article>
+       {{ content | safe }}
+</article>
diff --git a/_includes/layouts/review.njk b/_includes/layouts/review.njk
deleted file mode 100644 (file)
index 8dac2e6..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
----
-layout: layouts/base.njk
----
-
-<h1>{{ title }}</h1>
-
-<details>
-       <summary>Metadata</summary>
-       <ul>
-               <li>Published: <time datetime="{{ page.date | htmlDateString }}">{{ page.date | htmlDateString }}</time></li>
-               <li>Rating: {{ description }}</li>
-               <li>Tags: {{ tags | reject("equalto", "articles") | sort | join(", ") }}</li>
-               {%- if posse %}
-                       {%- include "components/posse.njk" %}
-               {%- endif %}
-       </ul>
-</details>
-
-<article>
-       {{ content | safe }}
-</article>
index 48b50762d5b2a55a4d5db298b355d2db591f573a..a007138f5c895187425c5f4a33d5bf13a9c3074f 100644 (file)
@@ -1,5 +1,5 @@
 {
     "tags": ["articles"],
-    "layout": "layouts/article.njk",
+    "layout": "layouts/post.njk",
     "permalink": "articles/{{ date | htmlDateString }}-{{ title | slugify }}/"
 }
\ No newline at end of file
index 68d72f06ec53c02eb34209bbc6375f8858f5af2c..203b3984e9c7565ca749d19085b5457d18a4951e 100644 (file)
@@ -1,5 +1,5 @@
 {
     "tags": ["links"],
-    "layout": "layouts/link.njk",
+    "layout": "layouts/post.njk",
     "permalink": "links/{{ date | htmlDateString }}-{{ title | slugify }}/"
 }
\ No newline at end of file
index 72ea2b8f91206a0f3dc9a01650cc7cb7d306b250..a4229ec0fb64e414d6032ec67dffb0de31450f3a 100644 (file)
@@ -1,5 +1,5 @@
 {
     "tags": ["reviews"],
-    "layout": "layouts/review.njk",
+    "layout": "layouts/post.njk",
     "permalink": "reviews/{{ date | htmlDateString }}-{{ title | slugify }}/"
 }
\ No newline at end of file
index df9d4bda727972ca995b6f07f188ab3518f9fab9..2d1a7f245cc0afccc43ff2790ff02ea9b006b767 100644 (file)
@@ -68,6 +68,9 @@ export default async function (eleventyConfig) {
        eleventyConfig.addFilter("min", (...numbers) => {
                return Math.min.apply(null, numbers);
        });
+       eleventyConfig.addFilter("startsWith", (str, prefix) => {
+               return str.startsWith(prefix);
+       });
        eleventyConfig.addPairedShortcode(
                "callout",
                function (content, level = "", format = "md", customLabel = "") {