generated from darkicewolf50/ssg-sveltekit-template
feat(master): added sitemap and readded ssg to contact page
This commit is contained in:
13
package-lock.json
generated
13
package-lock.json
generated
@ -7,6 +7,9 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "darkicewolf50",
|
"name": "darkicewolf50",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"date-fns": "^4.1.0"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.2.5",
|
"@eslint/compat": "^1.2.5",
|
||||||
"@eslint/js": "^9.31.0",
|
"@eslint/js": "^9.31.0",
|
||||||
@ -2000,6 +2003,16 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/date-fns": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/kossnocorp"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||||
|
@ -30,5 +30,8 @@
|
|||||||
"vite": "^7.0.5",
|
"vite": "^7.0.5",
|
||||||
"vite-plugin-devtools-json": "^0.3.0",
|
"vite-plugin-devtools-json": "^0.3.0",
|
||||||
"wrangler": "^4.25.0"
|
"wrangler": "^4.25.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"date-fns": "^4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
let { children } = $props();
|
||||||
import Top from '$lib/components/layout/Top.svelte';
|
import Top from '$lib/components/layout/Top.svelte';
|
||||||
import Bottom from '$lib/components/layout/Bottom.svelte';
|
import Bottom from '$lib/components/layout/Bottom.svelte';
|
||||||
let { children } = $props();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Top />
|
<Top />
|
||||||
|
1
src/routes/contact/+page.js
Normal file
1
src/routes/contact/+page.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const prerender = true;
|
@ -1,8 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import Contact from '$lib/components/contact.svelte';
|
import Contact from '$lib/components/contact.svelte';
|
||||||
|
|
||||||
export const prerender = true;
|
|
||||||
|
|
||||||
let contactName = $state('');
|
let contactName = $state('');
|
||||||
let contactEmail = $state('');
|
let contactEmail = $state('');
|
||||||
let contactMessage = $state('');
|
let contactMessage = $state('');
|
||||||
|
42
src/routes/sitemap.xml/+server.js
Normal file
42
src/routes/sitemap.xml/+server.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { format } from 'date-fns';
|
||||||
|
|
||||||
|
export const GET = async () => {
|
||||||
|
const baseUrl = 'https://yourdomain.com'; // Change to your domain
|
||||||
|
|
||||||
|
const staticPages = [
|
||||||
|
'', // homepage
|
||||||
|
'contact',
|
||||||
|
'projects'
|
||||||
|
// Add other pages here
|
||||||
|
];
|
||||||
|
|
||||||
|
const urls = staticPages
|
||||||
|
.map(
|
||||||
|
(path) => `
|
||||||
|
<url>
|
||||||
|
<loc>${baseUrl}/${path}</loc>
|
||||||
|
<lastmod>${format(new Date(), 'yyyy-MM-dd')}</lastmod>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>`
|
||||||
|
)
|
||||||
|
.join('');
|
||||||
|
|
||||||
|
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset
|
||||||
|
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
|
xmlns:xhtml="https://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0"
|
||||||
|
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
|
||||||
|
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
|
||||||
|
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
|
||||||
|
>
|
||||||
|
${urls}
|
||||||
|
</urlset>`;
|
||||||
|
|
||||||
|
return new Response(sitemap, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/xml'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
Reference in New Issue
Block a user