Skip to content

Commit eac9383

Browse files
committed
Fix issue with folder structure and huge html file on build. Also hopefully make Google like me again
1 parent b81e912 commit eac9383

File tree

7 files changed

+358
-281
lines changed

7 files changed

+358
-281
lines changed

package-lock.json

Lines changed: 325 additions & 268 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"postbuild": "svelte-sitemap --domain https://fantinel.dev"
1212
},
1313
"devDependencies": {
14-
"@sveltejs/adapter-static": "^1.0.0-next.17",
14+
"@sveltejs/adapter-static": "^1.0.0-next.29",
1515
"@sveltejs/kit": "next",
1616
"eslint": "^7.22.0",
1717
"eslint-config-prettier": "^8.1.0",

src/routes/[slug]/__layout.reset.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script context="module">
22
export async function load({ fetch, url }) {
3-
const jsonUrl = url.pathname + '.json';
3+
const jsonUrl = url.pathname.replace(/\/\s*$/, "") + '.json';
44
const res = await fetch(jsonUrl);
55
66
if (res.ok) {

src/routes/blog.json.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import posts from '$lib/posts';
22

33
export async function get() {
4-
const body = Object.keys(posts).map((slug) => ({
5-
slug,
6-
...posts[slug],
7-
}));
4+
const body = Object.keys(posts).map((index) => {
5+
const { slug, title, date, excerpt, tags, readingTime } = posts[index]
6+
return {
7+
slug,
8+
title,
9+
date,
10+
excerpt,
11+
tags,
12+
readingTime
13+
}
14+
});
815

916
return {
1017
status: 200,

src/routes/index.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<script context="module">
22
export async function load({ fetch }) {
3-
const url = '/posts.json?limit=4';
3+
const url = '/posts.json';
44
const res = await fetch(url);
55
6+
const test = await res.json()
7+
68
if (res.ok) {
79
return {
810
props: {
9-
posts: await res.json()
11+
posts: test
1012
}
1113
};
1214
}

src/routes/posts.json.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import posts from '$lib/posts';
22

33
export async function get() {
4-
const body = Object.keys(posts).slice(0, 4).map((slug) => ({
5-
slug,
6-
...posts[slug],
7-
}));
4+
const body = Object.keys(posts).slice(0, 4).map((index) => {
5+
const { slug, title, date, excerpt, tags, readingTime } = posts[index]
6+
return {
7+
slug,
8+
title,
9+
date,
10+
excerpt,
11+
tags,
12+
readingTime
13+
}
14+
});
815

916
return {
1017
status: 200,

svelte.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ const config = {
3535
extensions: extensions,
3636

3737
kit: {
38-
adapter: adapter()
38+
adapter: adapter(),
39+
prerender: {
40+
default: true
41+
},
42+
trailingSlash: 'always'
3943
}
4044
};
4145

0 commit comments

Comments
 (0)