feat(sitemap): add custom sitemap configuration and XSLT file

This commit is contained in:
2025-05-16 15:11:44 +02:00
parent 14209935f6
commit fd9545cc10
2 changed files with 109 additions and 1 deletions

View File

@ -10,7 +10,38 @@ export default defineConfig({
site: "https://jleibl.net",
integrations: [
react(),
sitemap(),
sitemap({
changefreq: "weekly",
priority: 1.0,
lastmod: new Date("2025-05-16"),
customPages: [
"https://jleibl.net/#about",
"https://jleibl.net/#work",
"https://jleibl.net/#hobby",
"https://jleibl.net/#contact",
],
i18n: {
defaultLocale: "en",
locales: {
en: "en-US",
},
},
serialize: (item) => {
if (item.url === "https://jleibl.net/") {
return {
...item,
img: [
{
url: "https://jleibl.net/profile-image-futu-style.jpg",
caption: "Jan-Marlon Leibl - Fullstack Developer",
},
],
};
}
return item;
},
xslURL: "/sitemap.xsl",
}),
icon({
include: {
ph: ["*"],

77
public/sitemap.xsl Normal file
View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap - Jan-Marlon Leibl</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
color: #333;
max-width: 75rem;
margin: 0 auto;
padding: 2rem;
}
table {
width: 100%;
border-collapse: collapse;
margin: 2rem 0;
}
th, td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid #eee;
}
th {
background: #f5f5f5;
font-weight: 600;
}
tr:hover {
background: #f9f9f9;
}
a {
color: #0066cc;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.header {
border-bottom: 1px solid #eee;
padding-bottom: 2rem;
margin-bottom: 2rem;
}
</style>
</head>
<body>
<div class="header">
<h1>XML Sitemap</h1>
<p>This is the sitemap for jleibl.net</p>
</div>
<table>
<tr>
<th>URL</th>
<th>Priority</th>
<th>Change Frequency</th>
<th>Last Modified</th>
</tr>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td>
<a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a>
</td>
<td><xsl:value-of select="sitemap:priority"/></td>
<td><xsl:value-of select="sitemap:changefreq"/></td>
<td><xsl:value-of select="sitemap:lastmod"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>