From 620e6e73910ac1c055b9eb7690fb6bedb95aae73 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Thu, 22 Aug 2024 21:50:44 +1000 Subject: [PATCH] Add linked data --- slices/main/templates/layouts/app.html.slim | 3 +++ slices/main/templates/posts/show.html.slim | 1 + slices/main/views/posts/show.rb | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/slices/main/templates/layouts/app.html.slim b/slices/main/templates/layouts/app.html.slim index 21a5098..2b75348 100644 --- a/slices/main/templates/layouts/app.html.slim +++ b/slices/main/templates/layouts/app.html.slim @@ -41,6 +41,9 @@ html x-data="{darkMode: $persist(false)}" :class="{'dark' : darkMode === true}" script type="speculationrules" == context.speculation_rules + script type="application/ld+json" + == context.content_for(:linked_data) + meta property="og:title" content="#{context.content_for(:title)}" meta property="og:type" content="website" meta property="og:url" content="#{context.content_for(:url)}" diff --git a/slices/main/templates/posts/show.html.slim b/slices/main/templates/posts/show.html.slim index 80ac02b..b8a83ec 100644 --- a/slices/main/templates/posts/show.html.slim +++ b/slices/main/templates/posts/show.html.slim @@ -1,6 +1,7 @@ - context.content_for(:title, "#{post.display_title} | ") - context.content_for(:url, post.permalink) - context.content_for(:image, post.key_image) +- context.content_for(:linked_data, linked_data) article class="h-entry" template @img-modal.window="imgModal = true; imgModalSrc = $event.detail.imgModalSrc; imgModalDesc = $event.detail.imgModalDesc;" x-if="imgModal" diff --git a/slices/main/views/posts/show.rb b/slices/main/views/posts/show.rb index 93586d6..6045443 100644 --- a/slices/main/views/posts/show.rb +++ b/slices/main/views/posts/show.rb @@ -54,6 +54,26 @@ module Main expose :likes do |post| post.webmentions.select { |w| w[:type] == "like" } end + + expose :linked_data do |post| + { + "@context": "https://schema.org", + "@type": "BlogPosting", + headline: post.name, + url: post.permalink, + author: { + "@type": "Person", + name: "Daniel Nitsikopoulos", + email: "hello@dnitza.com", + url: "https://dnitza.com" + }, + mainEntityOfPage: post.permalink, + image: post.key_image, + datePublished: post.published_at, + dateCreated: post.published_at, + dateModified: post.published_at + }.to_json + end end end end