]> git.otsuka.systems Git - cotsuka.github.io/commitdiff
iterate through categories
authorCameron Otsuka <cameron@otsuka.haus>
Fri, 21 Mar 2025 19:09:36 +0000 (12:09 -0700)
committerCameron Otsuka <cameron@otsuka.haus>
Fri, 21 Mar 2025 19:09:36 +0000 (12:09 -0700)
_data/socials.json
_includes/layouts/base.njk
eleventy.config.js

index 82a406809dd0d3dd23c9f1d631bd84e4d375aff0..f30fd6dc7da74cf96b59f71130b81bf3f33ad097 100644 (file)
@@ -1,26 +1,32 @@
-[
-    {
+{
+    "x": {
         "title": "𝕏",
-        "url": "https://x.com/CameronOtsuka"
+        "url": "https://x.com/CameronOtsuka",
+        "username": "@CameronOtsuka"
     },
-    {
+    "activitypub": {
         "title": "ActivityPub",
-        "url": "https://otsuka.social/@cameron"
+        "url": "https://otsuka.social/@cameron",
+        "username": "@cameron@otsuka.social"
     },
-    {
+    "bluesky": {
         "title": "Bluesky",
-        "url": "https://bsky.app/profile/otsuka.haus"
+        "url": "https://bsky.app/profile/otsuka.haus",
+        "username": "@otsuka.haus"
     },
-    {
+    "nostr": {
         "title": "Nostr",
-        "url": "https://primal.net/profile/npub1hzssq7wewjztvglpdvku92htx3sv2x5r9ycvqhvl9xrtt5fn629s3np693"
+        "url": "https://primal.net/profile/npub1hzssq7wewjztvglpdvku92htx3sv2x5r9ycvqhvl9xrtt5fn629s3np693",
+        "username": "cameron@otsuka.haus"
     },
-    {
+    "linkedin": {
         "title": "LinkedIn",
-        "url": "https://www.linkedin.com/in/cotsuka"
+        "url": "https://www.linkedin.com/in/cotsuka",
+        "username": "cotsuka"
     },
-    {
+    "github": {
         "title": "GitHub",
-        "url": "https://github.com/cotsuka"
+        "url": "https://github.com/cotsuka",
+        "username": "cotsuka"
     }
-]
\ No newline at end of file
+}
\ No newline at end of file
index b3731aa5d655bf4356c9b8c9097a52cfe27459b1..1b993848e45654252a279f2b48bb436df37904f2 100644 (file)
@@ -13,9 +13,9 @@
     <meta name="description" property="og:description" content="{{ description or metadata.subtitle }}" />
     <meta name="author" content="{{ metadata.author.name }}" />
     <meta name="generator" content="{{ eleventy.generator }}" />
-    <meta name="fediverse:creator" content="@cameron@otsuka.social" />
+    <meta name="fediverse:creator" content="{{ socials.activitypub.username }}" />
     <meta name="twitter:card" content="summary" />
-    <meta name="twitter:creator" content="@CameronOtsuka" />
+    <meta name="twitter:creator" content="{{ socials.x.username }}" />
     <meta name="twitter:title" content="{{ title }}" />
     <meta name="twitter:description" content="{{ description or metadata.subtitle }}" />
     <meta name="twitter:image" property="og:image" content="https://v1.screenshot.11ty.dev/{{ metadata.base | urlencode }}{{ page.url | urlencode }}/opengraph/9:16/" />
     <meta property="og:url" content="{{ metadata.base }}{{ page.url }}" />
     <meta property="og:site_name" content="{{ metadata.title }}" />
     <meta property="og:updated_time" content="{{ updated | isoDate }}" />
+    {%- set categories = metadata.categories | keys %}
     {%- if tags %}
         <meta property="og:type" content="article" />
         <meta property="article:published_time" content="{{ date | isoDate }}" />
         <meta property="article:modified_time" content="{{ updated | isoDate }}" />
         <meta property="article:author" content="{{ metadata.author.name }}" />
-        {%- for tag in tags | reject("equalto", "articles") | reject("equalto", "links") | reject("equalto", "reviews") %}
+        {%- for tag in tags | notIn(categories) %}
             <meta property="article:tag" content="{{ tag }}" />
         {%- endfor %}
     {%- else %}
@@ -41,9 +42,9 @@
     <link rel="icon" type="image/x-icon" href="/favicon.ico" />
     <link rel="canonical" href="{{ metadata.base }}{{ page.url }}" />
     <link rel="alternate" href="/feed.xml" type="application/atom+xml" title="{{ metadata.title }}" />
-    <link rel="alternate" href="/feeds/articles.xml" type="application/atom+xml" title="{{ metadata.title }} - Articles" />
-    <link rel="alternate" href="/feeds/links.xml" type="application/atom+xml" title="{{ metadata.title }} - Links" />
-    <link rel="alternate" href="/feeds/reviews.xml" type="application/atom+xml" title="{{ metadata.title }} - Reviews" />
+    {%- for category in categories %}
+        <link rel="alternate" href="/feeds/{{ category }}.xml" type="application/atom+xml" title="{{ metadata.title }} - {{ category | capitalize }}" />
+    {%- endfor %}
     <link rel="preload" href="/fonts/PublicSans-Bold.woff2" as="font" type="font/woff2" crossorigin />
     <link rel="preload" href="/fonts/PublicSans-BoldItalic.woff2" as="font" type="font/woff2" crossorigin />
     <link rel="preload" href="/fonts/PublicSans-Italic.woff2" as="font" type="font/woff2" crossorigin />
@@ -77,7 +78,7 @@
     <footer>
         <address>
             <menu>
-            {%- for social in socials %}
+            {%- for _, social in socials %}
                 <li><a href="{{ social.url }}" rel="me">{{ social.title }}</a></li>
             {%- endfor %}
             </menu>
index 149414d49cd5b5acddef7a39bab58794f8d823ed..cce651f903787be5cd187d07b68f4a574224999c 100644 (file)
@@ -64,9 +64,15 @@ export default async function (eleventyConfig) {
        eleventyConfig.addFilter("isoDate", (dateObj) => {
                return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toISO();
        });
+       eleventyConfig.addFilter("keys", function (obj) {
+               return Object.keys(obj);
+       });
        eleventyConfig.addFilter("min", (...numbers) => {
                return Math.min.apply(null, numbers);
        });
+       eleventyConfig.addFilter("notIn", (stringList, rejectList) => {
+               return stringList.filter(str => !rejectList.includes(str));
+       });
        eleventyConfig.addFilter("startsWith", (str, prefix) => {
                return str.startsWith(prefix);
        });