Skip to content

Commit 3370e3c

Browse files
author
NotYasho
committed
Added sitemap
1 parent 2c02a36 commit 3370e3c

File tree

13 files changed

+67
-136
lines changed

13 files changed

+67
-136
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"svelte-carousel": "^1.0.23",
2323
"svelte-check": "^2.9.2",
2424
"typescript": "^4.9.3",
25-
"vite": "^4.0.0",
26-
"vite-plugin-compression": "^0.5.1"
25+
"vite": "^4.0.0"
2726
},
2827
"type": "module",
2928
"dependencies": {

src/app.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon/favicon-16x16.png" />
99
<link rel="manifest" href="/img/favicon/site.webmanifest" />
1010
<link rel="shortcut icon" href="/favicon.png" />
11-
<link rel="preload" href="/fonts/fonts.css" as="style" />
1211
<meta name="msapplication-TileColor" content="#da532c" />
1312
<meta name="robots" content="max-image-preview:large" />
1413
<meta name="robots" content="index,follow" />
@@ -21,7 +20,7 @@
2120
%sveltekit.head%
2221
</head>
2322

24-
<body>
23+
<body data-sveltekit-preload-data="hover">
2524
<div style="display: contents">%sveltekit.body%</div>
2625
</body>
2726
</html>

src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import '$lib/styles/app.scss';
2+
import '../styles/app.scss';
33
import Jumper from '$lib/Other/Jumper.svelte';
44
import { fade } from 'svelte/transition';
55
import { onMount } from 'svelte';

src/routes/article/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Nav from '$lib/blogs/Nav.svelte';
33
import Header from '$lib/blogs/Header.svelte';
44
import 'highlight.js/styles/night-owl.css';
5-
import '$lib/styles/markdown.scss';
5+
import '../../styles/markdown.scss';
66
import Footer from '$lib/blogs/Footer.svelte';
77
</script>
88

src/routes/blogs/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Nav from '$lib/blogs/Nav.svelte';
33
import Header from '$lib/blogs/Header.svelte';
44
import Footer from '$lib/blogs/Footer.svelte';
5-
import '$lib/styles/markdown.scss';
5+
import '../../styles/markdown.scss';
66
</script>
77

88
<svelte:head>

src/routes/contact/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
22
import Nav from '$lib/blogs/Nav.svelte';
33
import Header from '$lib/blogs/Header.svelte';
4-
import '$lib/styles/markdown.scss';
4+
import '../../styles/markdown.scss';
55
import { fade } from 'svelte/transition';
66
import Footer from '$lib/blogs/Footer.svelte';
77
</script>

src/routes/sitemap.xml/+server.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import client from '$lib/blogs/sanityClient';
2+
3+
const siteUrl = 'https://notyasho.netlify.app/'
4+
5+
async function getPostsData() {
6+
const blogs = await client.fetch(`*[_type == "blog"]`)
7+
console.log(blogs)
8+
return blogs
9+
}
10+
11+
async function categories() {
12+
const categories = await client.fetch(`*[_type == "category"]`)
13+
console.log(categories)
14+
return categories
15+
}
16+
17+
export const GET = async () => {
18+
const pages = [
19+
'about',
20+
'contact',
21+
'blogs/saved',
22+
'blogs/explore',
23+
...await getPostsData().then((data) => data.map((post) => `article/${post.slug.current}`)),
24+
...await categories().then((data) => data.map((category) => `blogs/explore/${category.name}`)),
25+
]
26+
27+
const sitemap = `
28+
<?xml version="1.0" encoding="UTF-8" ?>
29+
<urlset
30+
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
31+
xmlns:xhtml="https://www.w3.org/1999/xhtml"
32+
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0"
33+
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
34+
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
35+
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
36+
>
37+
${pages
38+
.map((page) => {
39+
return `
40+
<url>
41+
<loc>${siteUrl}${page}</loc>
42+
<lastmod>${new Date().toISOString()}</lastmod>
43+
</url>
44+
`
45+
})
46+
.join('')}
47+
</urlset>
48+
`.trim()
49+
50+
return new Response(sitemap, {
51+
headers: {
52+
'Content-Type': 'application/xml',
53+
'Cache-Control': `public, max-age=0, s-maxage=${60 * 60 * 24}`,
54+
},
55+
})
56+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

static/sitemap.xml

-119
This file was deleted.

svelte.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import adapter from '@sveltejs/adapter-netlify';
44
const config = {
55
preprocess: preprocessor({
66
scss: {
7-
prependData: `@use './src/lib/styles/_variables.scss' as *;`
7+
prependData: `@use './src/styles/_variables.scss' as *;`
88
}
99
}),
1010
kit: {

vite.config.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { sveltekit } from '@sveltejs/kit/vite';
2-
import viteCompression from 'vite-plugin-compression';
1+
import { sveltekit } from '@sveltejs/kit/vite'
32

43
/** @type {import('vite').UserConfig} */
54
const config = {
6-
plugins: [sveltekit(), viteCompression()],
7-
server: {
8-
cors: true
9-
}
10-
};
5+
plugins: [sveltekit()],
6+
}
117

12-
export default config;
8+
export default config

0 commit comments

Comments
 (0)