diff options
author | dakkar <dakkar@thenautilus.net> | 2022-11-12 11:08:28 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2022-11-12 11:08:28 +0000 |
commit | 3287c79aa593926e8aeb2294a61cb1117aa3dcf9 (patch) | |
tree | 14a25e255ded3139b12e6d9e03babdb14236e61c /templates | |
parent | remove twitter sidebar ticker (diff) | |
download | thenautilus-3287c79aa593926e8aeb2294a61cb1117aa3dcf9.tar.gz thenautilus-3287c79aa593926e8aeb2294a61cb1117aa3dcf9.tar.bz2 thenautilus-3287c79aa593926e8aeb2294a61cb1117aa3dcf9.zip |
add opengraph meta
Diffstat (limited to 'templates')
-rw-r--r-- | templates/du2html.xsl | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/templates/du2html.xsl b/templates/du2html.xsl index 6f77e4c..fccee23 100644 --- a/templates/du2html.xsl +++ b/templates/du2html.xsl @@ -17,6 +17,14 @@ <x:param name="path"/> <x:param name="filename"/> + <x:variable name="locale"> + <x:choose> + <x:when test="$language = 'it'">it_IT</x:when> + <x:when test="$language = 'en'">en_GB</x:when> + <x:otherwise><!-- uh? --><x:value-of select="$language"/></x:otherwise> + </x:choose> + </x:variable> + <x:variable name="langs-rtf"> <x:choose> <x:when test="$language = 'it'"> @@ -160,15 +168,37 @@ <link rel="alternate" type="application/atom+xml" href="{$url}feed.{$language}.xml"/> </x:template> - <x:template match="image[contains(concat(' ',normalize-space(string(@classes)),' '),' twitter ')]" mode="twitter-card"> + <x:template match="image[contains(concat(' ',normalize-space(string(@classes)),' '),' preview ')]" mode="og-meta"> <x:variable name="uri-with-slash" select="wc:dst-uri-for(@uri,/document/@source)" /> <!-- dst-uri-for appends a / at the end :( --> - <meta name="twitter:image" content="https://www.thenautilus.net{substring($uri-with-slash,1,string-length($uri-with-slash) - 1)}" /> + <x:variable name="uri" select="substring($uri-with-slash,1,string-length($uri-with-slash) - 1)" /> + <meta name="twitter:image" content="https://www.thenautilus.net{$uri}" /> <x:if test="@alt"> <meta name="twitter:image:alt" content="{@alt}" /> </x:if> + <meta name="og:image" content="https://www.thenautilus.net{$uri}" /> + <x:if test="@alt"> + <meta name="og:image:alt" content="{@alt}" /> + </x:if> + </x:template> + <x:template match="image" mode="og-meta" priority="-1" /> + + <x:template match="/document" mode="og-description"> + <x:choose> + <x:when test="subtitle"> + <x:value-of select="normalize-space(subtitle)" /> + </x:when> + <x:otherwise> + <x:variable name="content"> + <x:apply-templates/> + </x:variable> + <x:value-of select="substring(normalize-space($content),0,200)"/> + <x:if test="string-length(normalize-space($content)) > 200"> + <x:text>…</x:text> + </x:if> + </x:otherwise> + </x:choose> </x:template> - <x:template match="image" mode="twitter-card" priority="-1" /> <x:template match="video"> <video controls="true" playsinline="true"> @@ -193,7 +223,7 @@ <x:template match="/document"> <html xml:lang="{$language}" lang="{$language}"> - <head> + <head prefix="og: https://ogp.me/ns#"> <title><x:value-of select="normalize-space(title)"/></title> <x:apply-templates select="." mode="stylesheet" /> <link rel="icon" type="image/png" href="/favicon.png" /> @@ -205,25 +235,20 @@ <meta name="twitter:card" content="summary" /> <meta name="twitter:site" content="@dakkar" /> <meta name="twitter:title" content="{normalize-space(title)}" /> - <x:apply-templates select="//image" mode="twitter-card" /> + <meta name="og:site_name" content="the Nautilus" /> + <meta name="og:title" content="{normalize-space(title)}" /> + <x:apply-templates select="//image" mode="og-meta" /> <meta name="twitter:description"> <x:attribute name="content"> - <x:choose> - <x:when test="subtitle"> - <x:value-of select="normalize-space(subtitle)" /> - </x:when> - <x:otherwise> - <x:variable name="content"> - <x:apply-templates/> - </x:variable> - <x:value-of select="substring(normalize-space($content),0,200)"/> - <x:if test="string-length(normalize-space($content)) > 200"> - <x:text>…</x:text> - </x:if> - </x:otherwise> - </x:choose> + <x:apply-templates mode="og-description" /> + </x:attribute> + </meta> + <meta name="og:description"> + <x:attribute name="content"> + <x:apply-templates mode="og-description" /> </x:attribute> </meta> + <meta name="og:locale" content="{$locale}" /> </head> <body> <div id="wrapper"> |