Skip to content

Commit

Permalink
Bug do sveltekit contornado sveltejs/kit#8676
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafezinhu committed Feb 14, 2023
1 parent 4eb2426 commit c06c0a9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
12 changes: 12 additions & 0 deletions src/components/Link.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
export let href: string;
function click(path: string, e: MouseEvent){
if(import.meta.env.DEV) return;
e.preventDefault();
window.location.href = `${path}.html`;
}
</script>

<a href={href} on:click={(e) => click(href, e)}>
<slot />
</a>
19 changes: 13 additions & 6 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import FaGithubSquare from 'svelte-icons/fa/FaGithubSquare.svelte';
import FaDiscord from 'svelte-icons/fa/FaDiscord.svelte';
import ContatoIcon from '../components/ContatoIcon.svelte';
import Link from '../components/Link.svelte';

let contatos: HTMLDivElement;

Expand All @@ -16,12 +17,18 @@
<p class="text-secondary-1 text-xl">Olá, meu nome é</p>
<h1 class="text-gray-200 text-5xl md:text-6xl lg:text-9xl mb-2">Aerton Oliveira</h1>
<h2 class="text-gray-300 text-xl">Sou desenvolvedor de software, construtor de sites, aplicativos e games.</h2>
<button
class="border-secondary-1 rounded-md border-2 text-secondary-1 hover:bg-secondary-1 hover:text-primary-4 transition-all text-xl p-1 mt-3"
on:click={scrollToContatos}>
Entrar em contato
</button>
<a class="border-tertiary-1 rounded-md border-2 text-tertiary-1 hover:bg-tertiary-1 hover:text-primary-4 transition-all text-xl p-1 ml-2 cursor-pointer" href="/blog">Blog</a>
<div class="flex mt-3">
<button
class="border-secondary-1 rounded-md border-2 text-secondary-1 hover:bg-secondary-1 hover:text-primary-4 transition-all text-xl p-1"
on:click={scrollToContatos}>
Entrar em contato
</button>
<Link href="/blog">
<div
class="border-tertiary-1 rounded-md border-2 text-tertiary-1 hover:bg-tertiary-1 hover:text-primary-4 transition-all text-xl p-1 ml-2 cursor-pointer"
>Blog</div>
</Link>
</div>
</div>
</main>

Expand Down
5 changes: 5 additions & 0 deletions src/routes/blog/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function load() {
return {
posts: ['testezinho', 'eae'],
}
}
14 changes: 13 additions & 1 deletion src/routes/blog/+page.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
<h1>Blog</h1>
<script lang="ts">
import Link from "../../components/Link.svelte";

export let data: {posts: string[]};
</script>

<h1>Blog</h1>
{#each data.posts as post}
<Link
href={`/blog/${post}`}
>post</Link>
{/each}
<!-- on:click={(e) => clickPost(post, e)} -->
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/utils/redirect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function redirectTo(path: string, e: MouseEvent){
e.preventDefault();
window.location.href = path;
}
2 changes: 1 addition & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
strict: true
}),
prerender: {
entries: ['*', '/blog/post/testezinho']
entries: ['*']
}
},
preprocess: vitePreprocess()
Expand Down

0 comments on commit c06c0a9

Please sign in to comment.