Skip to content

Commit

Permalink
Move blog header to blog page and add workaround for SSL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jackreimers committed Nov 6, 2023
1 parent d3c5db9 commit c2e532c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<script lang="ts">
import BlogHeader from '$lib/components/layout/header-blog.svelte';
import { PUBLIC_APP_ROOT } from '$env/static/public';
</script>

<BlogHeader />

<p>{PUBLIC_APP_ROOT}</p>
11 changes: 3 additions & 8 deletions src/routes/blog/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<script lang="ts">
import SvelteMarkdown from 'svelte-markdown';
import { page } from '$app/stores';
import BlogHeader from '$lib/components/layout/header-blog.svelte';
/** @type {import('./$types').PageData} */
export let data: any;
console.log('data', data);
</script>

<p>Slug: {$page.params.slug}</p>
<p>Type: {typeof $page.params.slug}</p>
<BlogHeader />

<p>Content: {data.content}</p>

<!--
<SvelteMarkdown source={load($page.params.slug)} />
-->
<SvelteMarkdown source={data.content} />
28 changes: 26 additions & 2 deletions src/routes/blog/[slug]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PUBLIC_APP_ROOT } from '$env/static/public';

//TODO: Move these to their own files
interface PageLoadRequest {
slug: string;
}
Expand All @@ -8,12 +9,35 @@ interface PageLoadResult {
content: string;
}

const mockContent = `
# This is a header
This is a paragraph.
* This is a list
* With two items
1. And a sublist
2. That is ordered
* With another
* Sublist inside
| And this is | A table |
|-------------|---------|
| With two | columns |
`;

/** @type {import('./$types').PageLoad} */
//TODO: Figure out what the type is for params
//@ts-ignore
export async function load({ params }): PageLoadResult {
const blogContent = await fetch(`${PUBLIC_APP_ROOT}/posts/test.md`);
return { content: await blogContent.text() };
//TODO: Fix certificate issue so fetch works when running locally - returning mock content for now
if (PUBLIC_APP_ROOT === 'https://localhost:5173') {
return { content: mockContent };
} else {
const blogContent = await fetch(`${PUBLIC_APP_ROOT}/posts/test.md`);
return { content: await blogContent.text() };
}

//throw error(404, 'Not found');
}

0 comments on commit c2e532c

Please sign in to comment.