Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-LD: Add alternativeHeadline from subtitle #631

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading