Skip to content

Commit

Permalink
Fix issue with folder structure and huge html file on build. Also hop…
Browse files Browse the repository at this point in the history
…efully make Google like me again
  • Loading branch information
matfantinel committed Mar 19, 2022
1 parent b81e912 commit eac9383
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 281 deletions.
593 changes: 325 additions & 268 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"postbuild": "svelte-sitemap --domain https://fantinel.dev"
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.17",
"@sveltejs/adapter-static": "^1.0.0-next.29",
"@sveltejs/kit": "next",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/routes/[slug]/__layout.reset.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script context="module">
export async function load({ fetch, url }) {
const jsonUrl = url.pathname + '.json';
const jsonUrl = url.pathname.replace(/\/\s*$/, "") + '.json';
const res = await fetch(jsonUrl);
if (res.ok) {
Expand Down
15 changes: 11 additions & 4 deletions src/routes/blog.json.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import posts from '$lib/posts';

export async function get() {
const body = Object.keys(posts).map((slug) => ({
slug,
...posts[slug],
}));
const body = Object.keys(posts).map((index) => {
const { slug, title, date, excerpt, tags, readingTime } = posts[index]
return {
slug,
title,
date,
excerpt,
tags,
readingTime
}
});

return {
status: 200,
Expand Down
6 changes: 4 additions & 2 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script context="module">
export async function load({ fetch }) {
const url = '/posts.json?limit=4';
const url = '/posts.json';
const res = await fetch(url);
const test = await res.json()
if (res.ok) {
return {
props: {
posts: await res.json()
posts: test
}
};
}
Expand Down
15 changes: 11 additions & 4 deletions src/routes/posts.json.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import posts from '$lib/posts';

export async function get() {
const body = Object.keys(posts).slice(0, 4).map((slug) => ({
slug,
...posts[slug],
}));
const body = Object.keys(posts).slice(0, 4).map((index) => {
const { slug, title, date, excerpt, tags, readingTime } = posts[index]
return {
slug,
title,
date,
excerpt,
tags,
readingTime
}
});

return {
status: 200,
Expand Down
6 changes: 5 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const config = {
extensions: extensions,

kit: {
adapter: adapter()
adapter: adapter(),
prerender: {
default: true
},
trailingSlash: 'always'

This comment has been minimized.

Copy link
@bartholomej

bartholomej Mar 19, 2022

Hi @matfantinel,
this line will solve the issue you wrote about in the svelte-sitemap repository ;)
bartholomej/svelte-sitemap#24

}
};

Expand Down

0 comments on commit eac9383

Please sign in to comment.