]> git.otsuka.systems Git - cotsuka.github.io/commitdiff
add opengraph meta
authorCameron Otsuka <cameron@otsuka.haus>
Mon, 5 Aug 2024 19:09:22 +0000 (12:09 -0700)
committerCameron Otsuka <cameron@otsuka.haus>
Mon, 5 Aug 2024 19:09:22 +0000 (12:09 -0700)
_data/metadata.json
_includes/articleslist.njk
_includes/layouts/base.njk
_includes/layouts/home.njk
eleventy.config.js

index 16c427da97d3e4b2ac72e69dd3b44b52b877467c..63ccf2523b33a9ecaa694c5c79ccf4bed7b2935b 100644 (file)
@@ -1,7 +1,7 @@
 {
     "title": "Cameron Otsuka",
-    "url": "https://otsuka.haus/",
-    "base": "https://otsuka.haus/",
+    "url": "https://otsuka.haus",
+    "base": "https://otsuka.haus",
     "language": "en",
     "subtitle": "The collection of Cameron's thoughts.",
     "description": "The collection of Cameron's thoughts.",
index 27419113fdd239855a914c53a492f9569866181a..91bd38f3cbe278968bcdb95a971a492964882f5c 100644 (file)
@@ -1,6 +1,6 @@
 <dl>
-{% for article in articleslist | reverse %}
+{%- for article in articleslist | reverse %}
     <dt><a href="{{ article.url }}">{{ article.data.title }}</a></dt>
     <dd>{{ article.data.description }}</dd>
-{% endfor %}
+{%- endfor %}
 </dl>
\ No newline at end of file
index ee8cd8e58c05240dba75370ea1b5f358ce45610a..7fbcb260465bea1c7c91db81ba389766f1c34b76 100644 (file)
@@ -1,18 +1,46 @@
 <!doctype html>
-<html lang="{{ metadata.language }}">
+<html lang="{{ metadata.language }}" prefix="og: http://ogp.me/ns#">
 <head>
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    {%- if modified -%}
+        {% set updated = modified %}
+    {%- else -%}
+        {% set updated = date %}
+    {%- endif %}
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="title" property="og:title" content="{{ title }}" />
+    <meta name="description" property="og:description" content="{{ description or metadata.description }}" />
+    <meta name="author" content="{{ metadata.author.name }}" />
+    <meta name="generator" content="{{ eleventy.generator }}" />
+    <meta name="twitter:card" content="summary" />
+    <meta name="twitter:creator" content="@CameronOtsuka" />
+    <meta name="twitter:title" content="{{ title }}" />
+    <meta name="twitter:description" content="{{ description or metadata.description }}" />
+    <meta property="og:locale" content="en_US" />
+    <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 }}" />
+    {%- 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") %}
+            <meta property="article:tag" content="{{ tag }}" />
+        {%- endfor %}
+    {%- else %}
+        <meta property="og:type" content="website" />
+    {%- endif %}
     <title>{{ title }} | {{ metadata.title }}</title>
-    <meta name="description" content="{{ description or metadata.description }}">
-    <link rel="icon" type="image/x-icon" href="/favicon.ico">
-    <link rel="alternate" href="/feed.xml" type="application/atom+xml" title="{{ metadata.title }}">
-    {% set css %}
+    <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 }}" />
+    {%- set css %}
         {% include "css/reset.css" %}
         {% include "css/style.css" %}
         {% include "css/public-sans.css" %}
         {% include "css/prism-okaidia.css" %}
-    {% endset %}
+    {%- endset %}
     <style>
         {{ css | cssmin | safe }}
     </style>
             </menu>
         </address>
         <p>
-            {% if modified %}
-                {% set updated = modified %}
-            {% else %}
-                {% set updated = date %}
-            {% endif %}
             Last Modified: <time datetime="{{ updated | htmlDateString }}">{{ updated | htmlDateString }}</time>
         </p>
         <p>All views my own. Not financial advice. Links, citations, and other references are not endorsements.</p>
index d3f87de9c016eca3cab91292621df4fb1b8248ab..f2350bcb026bad3bb4a76edb0bef11b26190dd41 100644 (file)
@@ -9,14 +9,14 @@ layout: layouts/base.njk
 <section>
     <h2>Articles</h2>
     {% set articleslist = collections.articles %}
-    {% include "articleslist.njk" %}
+    {%- include "articleslist.njk" %}
 </section>
 
 <section>
     <h2>Contributions</h2>
     <ul>
-    {% for contribution in contributions %}
+    {%- for contribution in contributions %}
         <li><a href="{{ contribution.url }}">{{ contribution.title }}</a></li>
-    {% endfor %}
+    {%- endfor %}
     </ul>
 </section>
\ No newline at end of file
index 3ce4c9448953943ced425d6cb95b2767725e8613..85f1b67fb6035966babef95e640dc4617e98252d 100644 (file)
@@ -29,9 +29,9 @@ module.exports = function (eleventyConfig) {
                // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
                return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
        });
-       eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
+       eleventyConfig.addFilter("isoDate", (dateObj) => {
                // Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
-               return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
+               return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toISO();
        });
        eleventyConfig.addPassthroughCopy({ "./static/": "/" });
        eleventyConfig.addPlugin(feedPlugin, {