-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
e00499d
commit 0d24ae4
Showing
15 changed files
with
110 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import type { LayoutServerLoad } from './$types'; | ||
import type { MdMeta } from '../api/content/types'; | ||
|
||
export const load = (async ({ fetch }) => { | ||
const res = await fetch('/api/content'); | ||
const response = await fetch('/api/content'); | ||
if (!response.ok) { | ||
throw error(400, 'error loading data from endpoint'); | ||
} | ||
|
||
return { | ||
posts: (await res.json()) as MdMeta[] | ||
posts: (await response.json()) as MdMeta[] | ||
}; | ||
}) satisfies LayoutServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageServerLoad } from './$types'; | ||
import type { MdBody } from '../../api/content/types'; | ||
|
||
export const load = (async ({ parent, params, fetch }) => { | ||
const { posts } = await parent(); | ||
|
||
// find index of file that matches the slug | ||
const postId = posts.findIndex((x) => x.slug === params.slug); | ||
|
||
const res = await fetch(`/api/content/${postId}`); | ||
const response = await fetch(`/api/content/${postId}`); | ||
if (!response.ok) { | ||
throw error(400, 'error loading data from endpoint'); | ||
} | ||
|
||
return { | ||
postBody: (await res.json()) as MdBody | ||
postBody: (await response.json()) as MdBody | ||
}; | ||
}) satisfies PageServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,41 @@ | ||
<script lang="ts"> | ||
import Tag from '$lib/components/Tag.svelte'; | ||
import type { PageServerData } from './$types'; | ||
export let data: PageServerData; | ||
const { meta, html } = data.postBody; | ||
</script> | ||
|
||
<article class="prose"> | ||
{@html data.postBody.html} | ||
</article> | ||
<svelte:head> | ||
<title>Posts | {meta.title}</title> | ||
<meta name="Post" content="Post" /> | ||
</svelte:head> | ||
|
||
<div> | ||
<div class="flex flex-col"> | ||
<h1>{meta.title}</h1> | ||
|
||
<div class="flex space-x-4"> | ||
<p>{meta.date}</p> | ||
<a href="/posts/categories">{meta.category}</a> | ||
</div> | ||
|
||
{#if meta.tags.length} | ||
<ul class="flex space-x-2"> | ||
{#each meta.tags as tag} | ||
<li> | ||
<Tag tagsPage="/posts/tags" {tag} /> | ||
</li> | ||
{/each} | ||
</ul> | ||
{/if} | ||
</div> | ||
|
||
<span> | ||
{meta.description} | ||
</span> | ||
|
||
<article class="prose"> | ||
{@html html} | ||
</article> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageServerLoad } from './$types'; | ||
import type { MdMeta } from '../../../api/content/types'; | ||
|
||
export const load = (async ({ params, fetch }) => { | ||
const response = await fetch('/api/content'); | ||
if (!response.ok) { | ||
throw error(400, 'error loading data from endpoint'); | ||
} | ||
|
||
const result = (await response.json()) as MdMeta[]; | ||
|
||
return { | ||
posts: result.filter((x) => x.category === params.slug) | ||
posts: result.filter((x) => x.category === params.slug), | ||
category: params.slug | ||
}; | ||
}) satisfies PageServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageServerLoad } from './$types'; | ||
import type { MdMeta } from '../../api/content/types'; | ||
import type { MdMeta } from '../../../api/content/types'; | ||
|
||
export const load = (async ({ params, fetch }) => { | ||
const response = await fetch('/api/content'); | ||
const result = (await response.json()) as MdMeta[]; | ||
if (!response.ok) { | ||
throw error(400, 'error loading data from endpoint'); | ||
} | ||
|
||
const allMatchedMetdata = result.filter((x) => x.tags.includes(params.slug)); | ||
const result = (await response.json()) as MdMeta[]; | ||
|
||
return { | ||
allMatchedMetdata | ||
posts: result.filter((x) => x.tags.includes(params.slug)), | ||
tag: params.slug | ||
}; | ||
}) satisfies PageServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters