diff options
author | dakkar <dakkar@thenautilus.net> | 2016-01-29 17:04:31 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2016-01-29 17:04:31 +0000 |
commit | 0afd5288c6ca1b0ad130a69b0439d16bab260cb7 (patch) | |
tree | c9ee6218f39125c2798b1bb280532f6bcb22cdd5 /templates/du2html.xsl | |
parent | add Twitter cards to all pages (diff) | |
download | thenautilus-0afd5288c6ca1b0ad130a69b0439d16bab260cb7.tar.gz thenautilus-0afd5288c6ca1b0ad130a69b0439d16bab260cb7.tar.bz2 thenautilus-0afd5288c6ca1b0ad130a69b0439d16bab260cb7.zip |
better twitter cards
Diffstat (limited to 'templates/du2html.xsl')
-rw-r--r-- | templates/du2html.xsl | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/templates/du2html.xsl b/templates/du2html.xsl index db8ce3c..55fdcd7 100644 --- a/templates/du2html.xsl +++ b/templates/du2html.xsl @@ -177,9 +177,24 @@ <meta name="twitter:card" content="summary" /> <meta name="twitter:site" content="@dakkar" /> <meta name="twitter:title" content="{normalize-space(title)}" /> - <x:if test="subtitle"> - <meta name="twitter:description" content="{normalize-space(subtitle)}" /> - </x:if> + <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:attribute> + </meta> </head> <body> <div id="wrapper"> |