Add og props

This commit is contained in:
2024-02-02 18:44:15 +11:00
parent 6bbdca228e
commit d26c3759ac
3 changed files with 19 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
require "rexml/parsers/pullparser" require "rexml/parsers/pullparser"
require "sanitize" require "sanitize"
require "nokogiri"
module Adamantium module Adamantium
module Decorators module Decorators
@@ -38,6 +39,16 @@ module Adamantium
__getobj__.photos.select { |p| p["value"].end_with?("mp4") } __getobj__.photos.select { |p| p["value"].end_with?("mp4") }
end end
def key_image
if photos?
return photos.first["url"]
end
doc = Nokogiri::HTML(content)
images = doc.at("//img")
images.first[1] if images
end
def prefix_emoji def prefix_emoji
if name if name
"" ""

View File

@@ -38,6 +38,12 @@ html x-data="{darkMode: $persist(false)}" :class="{'dark' : darkMode === true}"
link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.8.0/styles/github-dark.min.css" link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.8.0/styles/github-dark.min.css"
script src="https://unpkg.com/@highlightjs/cdn-assets@11.8.0/highlight.min.js" defer="" script src="https://unpkg.com/@highlightjs/cdn-assets@11.8.0/highlight.min.js" defer=""
meta property="og:title" content="#{context.content_for(:title)}"
meta property="og:type" content="website"
meta property="og:url" content="#{context.content_for(:url)}"
- if context.content_for(:image)
meta property="og:image" content="#{context.content_for(:image)}"
- if Hanami.app.settings.micropub_pub_key - if Hanami.app.settings.micropub_pub_key
link rel="pgpkey" href="/key" link rel="pgpkey" href="/key"
body class="transition-colors bg-white dark:bg-indigo-950 selection:bg-blue-100 selection:text-blue-900 dark:selection:bg-amber-600 dark:selection:text-amber-400" x-data="{ imgModal : false, imgModalSrc : '', imgModalDesc : '' }" x-on:keydown.escape="imgModal=false" body class="transition-colors bg-white dark:bg-indigo-950 selection:bg-blue-100 selection:text-blue-900 dark:selection:bg-amber-600 dark:selection:text-amber-400" x-data="{ imgModal : false, imgModalSrc : '', imgModalDesc : '' }" x-on:keydown.escape="imgModal=false"

View File

@@ -1,4 +1,6 @@
- context.content_for(:title, "#{post.display_title} | ") - context.content_for(:title, "#{post.display_title} | ")
- context.content_for(:url, post.permalink)
- context.content_for(:image, post.key_image)
article class="h-entry" article class="h-entry"
template @img-modal.window="imgModal = true; imgModalSrc = $event.detail.imgModalSrc; imgModalDesc = $event.detail.imgModalDesc;" x-if="imgModal" template @img-modal.window="imgModal = true; imgModalSrc = $event.detail.imgModalSrc; imgModalDesc = $event.detail.imgModalDesc;" x-if="imgModal"