-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🩹 Fixed API integration with blog posts
- Loading branch information
Showing
14 changed files
with
496 additions
and
529 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,9 +1,9 @@ | ||
import type { RequestEvent } from "@sveltejs/kit"; | ||
import type { inferAsyncReturnType } from "@trpc/server"; | ||
import type { RequestEvent } from "@sveltejs/kit"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export async function createContext(event: RequestEvent) { | ||
export const createContext = async (event: RequestEvent) => { | ||
return {}; | ||
} | ||
}; | ||
|
||
export type Context = inferAsyncReturnType<typeof createContext>; |
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,25 +1,28 @@ | ||
import { error, type LoadEvent } from "@sveltejs/kit"; | ||
import { trpc } from "$lib/trpc/client"; | ||
import { error } from "@sveltejs/kit"; | ||
|
||
import type { PageLoad } from "./$types"; | ||
import type { Post } from "$lib/utils/types.js"; | ||
import type { PageLoad } from "./$types"; | ||
|
||
export const load: PageLoad = async (event) => { | ||
try { | ||
const params = event.params; | ||
const parent = event.parent; | ||
export const load: PageLoad = async (event: LoadEvent) => { | ||
const slug = event.params.slug ?? ""; | ||
const parent = event.parent; | ||
|
||
const { queryClient } = await parent(); | ||
const postQuery = await queryClient.fetchQuery({ | ||
queryFn: () => trpc(event).posts.fetchPosts.query({ slug: params.slug.toLowerCase() }), | ||
queryKey: ["post"] | ||
}); | ||
const { queryClient } = await parent(); | ||
const postQuery = await queryClient.fetchQuery({ | ||
queryFn: () => | ||
trpc(event).posts.fetchPosts.query({ | ||
slug: slug | ||
}), | ||
queryKey: ["post"] | ||
}); | ||
|
||
const post: Post = postQuery[0]; | ||
return { | ||
post | ||
}; | ||
} catch (e) { | ||
const post: Post = postQuery[0]; | ||
if (!post) { | ||
throw error(404); | ||
} | ||
|
||
return { | ||
post | ||
}; | ||
}; |
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 was deleted.
Oops, something went wrong.