Skip to content

Commit

Permalink
JSON-LD: Add alternativeHeadline from subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
tomschr committed May 23, 2024
1 parent 3dae7af commit 766bd3a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@
<xsl:call-template name="json-ld-headline">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-alternativeheadline">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-description">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
Expand Down Expand Up @@ -513,6 +516,27 @@
"headline": "<xsl:value-of select="translate($headline, '&quot;', '')"/>",
</xsl:template>


<xsl:template name="json-ld-alternativeheadline">
<xsl:param name="node" select="."/>
<xsl:variable name="candidate-headline">
<xsl:choose>
<xsl:when test="$node/d:info/d:subtitle">
<xsl:value-of select="$node/d:info/d:subtitle"/>
</xsl:when>
<xsl:when test="$node/d:subtitle">
<xsl:value-of select="$node/d:subtitle"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="subtitle" select="normalize-space($candidate-headline)"/>

<xsl:if test="$subtitle != ''">
<xsl:text> "alternativeHeadline": </xsl:text>
<xsl:value-of select="concat('&quot;', $subtitle, '&quot;,')"/>
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-language">
<xsl:param name="node" select="."/>
<xsl:variable name="candidate-lang" select="($node/ancestor-or-self::*/@xml:lang)[last()]"/>
Expand Down

0 comments on commit 766bd3a

Please sign in to comment.