Skip to content

Commit

Permalink
Added the missing XSLT file
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Feb 1, 2025
1 parent 6a86a49 commit 963cd42
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions static/sitemap.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
>
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:message>Powered by <a href="https://www.sitemap.style/">Sitemap Style</a></xsl:message>

<!-- get the hostname from the first url/loc -->
<xsl:variable name="hostname" select="substring-before(substring-after(/sitemap:urlset/sitemap:url[1]/sitemap:loc, '://'), '/')" />

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="referrer" content="unsafe-url" />
<title>Sitemap for <xsl:value-of select="$hostname"/></title>
<link rel="stylesheet" href="https://www.sitemap.style/css/water.min.css" />
<script>
window.addEventListener('load', function() {
var viewPara = document.getElementById("viewpara");
viewPara.style.display = "block";
var viewLink = document.getElementById("viewlink");
viewLink.href = `https://sitemap-viewer.fileformat.info/view.html?url=${encodeURIComponent(window.location.href)}`;
});
</script>
</head>
<body>
<h1>Pages on <xsl:value-of select="$hostname"/></h1>

<p id="viewpara" style="display:none;">
<a id="viewlink" href="">View as a tree</a>
</p>

<ul>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<xsl:variable name="sitemap_loc"><xsl:value-of select="sitemap:loc"/></xsl:variable>
<xsl:variable name="sitemap_lastmod"><xsl:value-of select="sitemap:lastmod"/></xsl:variable>
<li>
<a href="{$sitemap_loc}"><xsl:value-of select="sitemap:loc" /></a>
<xsl:if test="$sitemap_lastmod!=''">
(<xsl:value-of select="sitemap:lastmod" />)
</xsl:if>
</li>
</xsl:for-each>
</ul>
<p><xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> pages</p>
<p><small>Powered by <a href="https://www.sitemap.style/"><img referrerpolicy="origin" src="https://www.sitemap.style/favicon.svg" style="height:1em;padding-right:0.25em;vertical-align:middle;" />Sitemap.Style</a></small></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 963cd42

Please sign in to comment.