Skip to content

Commit

Permalink
fix browser issues
Browse files Browse the repository at this point in the history
  • Loading branch information
grmbyrn committed Jan 20, 2025
1 parent 68964e3 commit 50133fa
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 483 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

src/routes/blog/**/*.md
63 changes: 36 additions & 27 deletions src/lib/components/molecules/CodeBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,24 @@
</script>

<div class="code-block" class:full-bleed={fullBleed} bind:this={codeBlockElement}>
{#if filename}
<div class="filename">{filename}</div>
{/if}
{#if lang}
<div class="lang">{lang}</div>
{/if}
<button
class={`copy-button ${showCheckmark ? 'copy-button-green' : 'copy-button-gray'}`}
onclick={copyToClipboard}
>
{#if showCheckmark}
<Icon icon="charm:tick" color="#6cdb2e" />
{:else}
<Icon icon="ion:copy-outline" color="#FFFFFF" />
<div class="code-block-info">
{#if filename}
<div class="filename">{filename}</div>
{/if}
</button>
{#if lang}
<div class="lang">{lang}</div>
{/if}
<button
class={`copy-button ${showCheckmark ? 'copy-button-green' : 'copy-button-gray'}`}
onclick={copyToClipboard}
>
{#if showCheckmark}
Code Copied <Icon icon="charm:tick" color="#6cdb2e" />
{:else}
Copy Code<Icon icon="ion:copy-outline" color="#FFFFFF" />
{/if}
</button>
</div>
<div class="code-content">
{#if code}
<pre><code
Expand All @@ -85,10 +87,10 @@
line-height: 1.33em;
border-radius: 8px;
box-shadow: var(--card-shadow);
padding: 12px 10px 20px 10px;
padding: 0 0 20px 0;
min-height: 80px;
background-color: #282c34 !important;
border: 1px solid gray;
margin: 30px 0;
:global(pre) {
Expand All @@ -111,17 +113,21 @@
.code-content code {
border-radius: 8px;
margin: 1rem 0.5rem 0 0.5rem;
padding: 20px;
}
.code-block-info {
display: flex;
justify-content: space-between;
border-bottom: 1px solid gray;
padding: 0.3rem 0.5rem;
}
.lang {
position: absolute;
right: 0;
top: -15px;
background-color: rgba(36, 36, 36, 1);
border-radius: 8px;
padding: 5px 10px;
z-index: 2;
font-size: 0.85em;
font-size: 1em;
}
.filename {
Expand All @@ -137,13 +143,16 @@
}
.copy-button {
position: absolute;
top: 1.5rem;
right: 1.5rem;
padding: 0.25rem;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid gray;
border-radius: 0.375rem;
gap: 0.5rem;
padding: 0.25rem 0.5rem;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
cursor: pointer;
font-size: 0.85em;
}
.copy-button-green {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/components/molecules/PostTable.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- @migration-task Error while migrating Svelte code: Can't migrate code with afterUpdate. Please migrate by hand. -->
<script lang="ts">
import { onMount } from 'svelte';
Expand All @@ -13,12 +12,14 @@
}
};
onMount(updateStyles);
onMount(() => {
updateStyles();
});
$: updateStyles();
</script>

<svelte:window bind:innerWidth={size} />
<svelte:window on:resize={() => (size = window.innerWidth)} />

<div class={size >= 1440 ? 'scroll-container' : ''} style={divStyle}>
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/singletons/PrevNextPost.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<a href="/blog/{prevPost.meta.slug}">{prevPost?.meta?.title}</a>
</div>
{:else}
<h3 class="inactive">You are reading our first post.</h3>
<h3 class="inactive">You are reading our most recent post.</h3>
{/if}
</div>

Expand Down
9 changes: 0 additions & 9 deletions src/lib/data/blog-posts/index.ts

This file was deleted.

80 changes: 0 additions & 80 deletions src/lib/data/blog-posts/utils.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/utils/index_posts.ts → src/lib/data/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ export const fetchMarkdownPosts = async () => {
};
})
);

return allPosts;
};
2 changes: 1 addition & 1 deletion src/routes/(home)/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchMarkdownPosts } from '$lib/utils/index_posts';
import { fetchMarkdownPosts } from '$lib/data/posts';
import type { Contributor } from '$lib/utils/types';
import { fetchWithCache } from '$lib/utils/cache';

Expand Down
17 changes: 13 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@
import Header from '$lib/components/organisms/Header.svelte';
import Footer from '$lib/components/organisms/Footer.svelte';
import { onNavigate } from '$app/navigation';
let contentDiv: HTMLElement | null = null;
const supportsViewTransition = typeof window !== 'undefined' && 'startViewTransition' in document;
onNavigate((navigation) => {
return new Promise((resolve) => {
const transition = document.startViewTransition(async () => {
if (supportsViewTransition) {
const transition = document.startViewTransition(async () => {
if (contentDiv) {
contentDiv.scrollTop = 0;
}
resolve();
await navigation.complete;
});
} else {
if (contentDiv) {
// Fix scroll
contentDiv.scrollTop = 0;
}
resolve();
await navigation.complete;
});
}
});
});
Expand Down
9 changes: 5 additions & 4 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export const prerender = true;

import { filteredPosts } from '$lib/data/blog-posts';
export const load = async ({ fetch }) => {
const response = await fetch(`/api`);
const posts = await response.json();

export async function load() {
return {
posts: filteredPosts
posts
};
}
};
2 changes: 1 addition & 1 deletion src/routes/api/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchMarkdownPosts } from '$lib/utils/index_posts';
import { fetchMarkdownPosts } from '$lib/data/posts';
import { json } from '@sveltejs/kit';

export const GET = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/blog/[slug]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchMarkdownPosts } from '$lib/utils/index_posts';
import { fetchMarkdownPosts } from '$lib/data/posts';

export async function load({ params }) {
const post = await import(`../${params.slug}.md`);
Expand Down
Loading

0 comments on commit 50133fa

Please sign in to comment.