You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bm...@apache.org on 2021/10/15 11:23:51 UTC

[shiro-site] branch jbake updated: absolute URI for og:image and twitter:image

This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch jbake
in repository https://gitbox.apache.org/repos/asf/shiro-site.git


The following commit(s) were added to refs/heads/jbake by this push:
     new 3cdd340  absolute URI for og:image and twitter:image
     new 3cdb108  Merge pull request #124 from bmarwell/jbake-header-absolute-url
3cdd340 is described below

commit 3cdd3402029d69bae256dec35b55f9642b585016
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Fri Oct 15 06:42:55 2021 +0200

    absolute URI for og:image and twitter:image
---
 jbake/templates/header.ftl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/jbake/templates/header.ftl b/jbake/templates/header.ftl
index 822246d..522f6ff 100644
--- a/jbake/templates/header.ftl
+++ b/jbake/templates/header.ftl
@@ -89,8 +89,15 @@
     <#else></#if>
     <#-- custom featured image if it exists or default featured image. -->
     <#if (content.featuredimage)?? >
+      <#if (content.featuredimage)?starts_with("http") || (content.featuredimage)?starts_with("/")>
     <meta property="og:image" content="${content.featuredimage}"/>
     <meta property="twitter:image" content="${content.featuredimage}"/>
+      <#else>
+        <#-- relative URI starting with ./ or directly with the image name. -->
+        <#assign imageprefix="${config.site_host}/${(content.uri?substring(0, content.uri?last_index_of('/')))}/" />
+    <meta property="og:image" content="${imageprefix}${content.featuredimage}"/>
+    <meta property="twitter:image" content="${imageprefix}${content.featuredimage}"/>
+      </#if>
       <#if (content.featuredimagewidth)??>
     <meta property="og:image:width" content="${content.featuredimagewidth}"/>
       </#if>