-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68b1c27
commit a4298af
Showing
5 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getAll, initialize } from "~/components/Library"; | ||
|
||
function urlLine(url:string) { | ||
return `\t<url><loc>https://www.regex.zone${url}</loc></url>` | ||
} | ||
|
||
export async function loader() { | ||
|
||
const lines:string[] = []; | ||
|
||
lines.push("<?xml version='1.0' encoding='UTF-8'?>"); | ||
lines.push('<?xml-stylesheet type="text/xsl" href="/sitemap.xslt" ?>'); | ||
lines.push('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">'); | ||
lines.push(urlLine('/')); | ||
lines.push(urlLine('/library/')); | ||
lines.push(urlLine('/library/tags.html')); | ||
lines.push(urlLine('/search.html')); | ||
|
||
initialize(); | ||
for (const entry of getAll()) { | ||
lines.push(urlLine(`/library/${entry.handle}/`)); | ||
} | ||
|
||
lines.push('</urlset>') | ||
|
||
return new Response(lines.join('\n'), { | ||
headers: { | ||
"Content-Type": "text/xml; charset=utf-8", | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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/pico.classless.min.css" /> | ||
</head> | ||
<body> | ||
<main class="container"> | ||
<h1>Pages on <xsl:value-of select="$hostname"/></h1> | ||
<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> | ||
</main> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
</xsl:stylesheet> |