2022-12-30 22:32:49 +05:30
|
|
|
import type { PageServerLoad } from "./$types";
|
2023-01-25 22:41:11 +05:30
|
|
|
import fetchGhost from "../../fetchGhost";
|
2022-12-30 22:32:49 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
export const load = (async ({ params, fetch }) => {
|
|
|
|
const data = await fetchGhost("posts", "&filter=tags:" + params.tag);
|
2022-12-30 22:32:49 +05:30
|
|
|
|
2023-01-25 22:41:11 +05:30
|
|
|
const tagsLoop = !data.error ? data.posts[0].tags.map((tag: { slug: string; name: any; }) => {
|
2023-01-02 00:20:51 +05:30
|
|
|
if (tag.slug === params.tag) {
|
|
|
|
return tag.name;
|
|
|
|
}
|
2023-01-25 22:41:11 +05:30
|
|
|
}) : [];
|
|
|
|
|
|
|
|
const tagName = tagsLoop.filter((tag: any) => tag !== undefined)[0];
|
|
|
|
|
|
|
|
const meta = {
|
|
|
|
title: "Blog tag " + tagName
|
|
|
|
}
|
2023-01-02 00:20:51 +05:30
|
|
|
|
2023-01-01 04:51:53 +05:30
|
|
|
return {
|
2023-01-25 22:41:11 +05:30
|
|
|
posts: data,
|
|
|
|
tagName: tagName,
|
|
|
|
...meta
|
2022-12-30 22:32:49 +05:30
|
|
|
}
|
2023-01-25 22:41:11 +05:30
|
|
|
}) satisfies PageServerLoad;
|