Skip to content

Commit

Permalink
Correct metadata
Browse files Browse the repository at this point in the history
* Rename abstract -> description and refactor code
* Introduce "sameAs" property
* Disable json-ld-version and json-ld-keywords
* Use "Corporation" instead of "Organization" for default author
  and publisher
  • Loading branch information
tomschr committed Aug 2, 2023
1 parent bc1cd13 commit 6201e75
Showing 1 changed file with 65 additions and 34 deletions.
99 changes: 65 additions & 34 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@type": "TechArticle",
"name": "Getting Started with ExampleApp",
"headline": "ExampleApp Documentation",
"abstract": "A short abstract of ExampleApp",
"description": "A comprehensive guide to get started with ExampleApp.",
"author": {
"@type": "Person",
Expand All @@ -28,6 +27,12 @@
},
"datePublished": "2023-07-24",
"dateModified": "2023-07-25",
"sameAs": [
"https://www.facebook.com/SUSEWorldwide/about",
"https://www.youtube.com/channel/UCHTfqIzPKz4f_dri36lAQGA",
"https://twitter.com/SUSE",
"https://www.linkedin.com/company/suse"
],
"publisher": {
"@type": "Organization",
"name": "SUSE",
Expand Down Expand Up @@ -61,13 +66,14 @@
-->
<xsl:call-template name="json-ld-headline"/>
<xsl:call-template name="json-ld-abstract"/>
<xsl:call-template name="json-ld-keywords"/>
<xsl:call-template name="json-ld-description"/>
<!-- <xsl:call-template name="json-ld-keywords"/>-->

<xsl:call-template name="json-ld-license"/><!-- Later -->
<xsl:call-template name="json-ld-authors-and-authorgroups"/>
<xsl:call-template name="json-ld-datePublished"/>
<xsl:call-template name="json-ld-dateModified"/>
<xsl:call-template name="json-ld-version"/>
<!-- <xsl:call-template name="json-ld-version"/>-->
<xsl:call-template name="json-ld-publisher"/>
}
</script>
Expand All @@ -81,33 +87,42 @@
"headline": "<xsl:value-of select="normalize-space($headline)"/>",
</xsl:template>

<xsl:template name="json-ld-abstract">
<xsl:template name="json-ld-description">
<xsl:param name="node" select="."/>
<xsl:if test="$node/d:info/d:abstract">
<xsl:variable name="abstract">
<xsl:call-template name="ellipsize.text">
<xsl:with-param name="input">
<xsl:choose>
<xsl:when test="$node/d:info/d:meta[@name = 'description']">
<xsl:value-of select="normalize-space($node/d:info/d:meta[@name = 'description'][1])" />
</xsl:when>
<xsl:when test="$node/d:info/d:abstract or $node/d:info/d:highlights">
<xsl:for-each select="($node/d:info[1]/d:abstract[1] | $node/d:info[1]/d:highlights[1])[1]/*">
<xsl:value-of select="normalize-space(.)" />
<xsl:if test="position() &lt; last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="description">
<xsl:choose>
<xsl:when test="$node/d:info/d:meta[@name = 'description']">
<xsl:value-of select="normalize-space($node/d:info/d:meta[@name = 'description'][1])"
/>
</xsl:when>
<xsl:when test="$node/d:info/d:meta[@name = 'social-descr']">
<xsl:value-of select="normalize-space($node/d:info/d:meta[@name = 'social-descr'][1])"
/>
</xsl:when>
<xsl:when test="$node/d:info/d:meta[@name = 'title']">
<xsl:value-of select="normalize-space($node/d:info/d:meta[@name = 'title'][1])"
/>
</xsl:when>
<xsl:when test="$node/d:info/d:abstract">
<xsl:call-template name="ellipsize.text">
<xsl:with-param name="input"
select="($node/d:info/d:abstract/d:para[1] |
$node/d:info/d:abstract/d:variablelist[1]/d:varlistentry[1]/d:listitem/d:para[1])[last()]">
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Only for fallback, if all of the above fails -->
<xsl:call-template name="ellipsize.text">
<xsl:with-param name="input" select="($node/d:info/d:title | $node/d:title)[last()]"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:if test="$abstract != ''">
"abstract": "<xsl:value-of select="$abstract"/>",
<xsl:if test="$description != ''">
"description": "<xsl:value-of select="$description"/>",
</xsl:if>
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-keywords">
Expand All @@ -124,6 +139,15 @@
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-license">
<xsl:param name="node" select="."/>

<!-- "license": "URL",
"copyrightNotice": "© 2023 ExampleTech Company. All rights reserved.",
"copyrightYear": "2023",
-->
</xsl:template>

<xsl:template name="json-ld-authors-and-authorgroups">
<xsl:param name="node" select="."/>
<!--
Expand Down Expand Up @@ -205,12 +229,12 @@
<xsl:template name="json-ld-author-fallback">
<xsl:param name="node" select="."/>
"author": {
"@type": "Organization",
"@type": "Corporation",
"name": "<xsl:value-of select="$json-ld-fallback-author"/>",
<xsl:if test="$json-ld-fallback-author-url != ''"
>"url": "<xsl:value-of select="$json-ld-fallback-author-url"/>",</xsl:if>
<xsl:if test="$json-ld-fallback-author-logo != ''"
>"logo": "<xsl:value-of select="$json-ld-fallback-author-logo"/>"</xsl:if>
<xsl:if test="$json-ld-fallback-author-logo != ''">
"logo": "<xsl:value-of select="$json-ld-fallback-author-logo"/>"</xsl:if>
},
</xsl:template>

Expand Down Expand Up @@ -268,10 +292,10 @@
<xsl:when test="$node/d:info/d:meta[@name='published']">
<xsl:value-of select="normalize-space(string($node/d:info/d:meta[@name='published']))"/>
</xsl:when>
<xsl:when test="$node/d:info/d:pubdate">
<xsl:when test="normalize-space($node/d:info/d:pubdate) != ''">
<xsl:value-of select="normalize-space(string($node/d:info/d:pubdate))"/>
</xsl:when>
<xsl:when test="$node/d:info/d:date">
<xsl:when test="normalize-space($node/d:info/d:date) != ''">
<xsl:value-of select="normalize-space(string($node/d:info/d:pubdate))"/>
</xsl:when>
<xsl:when test="$node/d:info/d:revhistory/d:revision[1]/d:date">
Expand Down Expand Up @@ -326,9 +350,16 @@
</xsl:template>

<xsl:template name="json-ld-publisher">
"sameAs": [
"https://www.facebook.com/SUSEWorldwide/about",
"https://www.youtube.com/channel/UCHTfqIzPKz4f_dri36lAQGA",
"https://twitter.com/SUSE",
"https://www.linkedin.com/company/suse"
],
"publisher": {
"@type": "Organization",
"@type": "Corporation",
"name": "SUSE",
"url": "https://documentation.suse.com",
"logo": {
"@type": "ImageObject",
"url": "https://www.suse.com/assets/img/suse-white-logo-green.svg"
Expand Down

0 comments on commit 6201e75

Please sign in to comment.