This commit is contained in:
Akis
2025-07-17 15:41:14 +03:00
committed by GitHub
parent 5229f07f59
commit 7ac6dd54c8
4 changed files with 25 additions and 18 deletions

View File

@@ -41,6 +41,9 @@ The website has the following **mandatory** environment variables
| :----------------- | :--------------------------------------------- |
| GHOST_URL | Your Ghost CMS URL |
| GHOST_API_KEY | Your Ghost CMS API key |
| GHOST_ALLPOSTS_URL | Your URL for all ghost posts, see below |
| KUMA_URL | Your Uptime Kuma announcements URL |
| ORIGIN | Your domain |
| ADDRESS_HEADER | Header used to retrieve client IP (Caddy only) |
> GHOST_ALLPOSTS_URL should be of the form `https://GHOST_URL/ghost/api/content/posts/?key=GHOST_API_KEY&include=authors,tags&limit=all&formats=html,plaintext`

View File

@@ -58,7 +58,10 @@ const updateMap = async () => {
}
try {
const res = await fetchGhost("posts");
const res = await axios(env.GHOST_ALLPOSTS_URL, {
httpsAgent: agent,
timeout: 10000
});
if (res.status === 200) {
blogPosts.set(res.data);

View File

@@ -13,9 +13,7 @@
text: "Wiki",
external: true
},
// Temporary workaround.
//{ href: "/blog", text: "Blog" },
{ href: "https://blog.projectsegfau.lt", text: "Blog" },
{ href: "/blog", text: "Blog" },
{ href: "/donate", text: "Donate" },
{ href: "/contact", text: "Contact" },

View File

@@ -1,19 +1,22 @@
import type { PageServerLoad } from "./$types";
import fetchGhost from "../fetchGhost";
import type { PageServerLoad, PageServerLoadEvent } from "./$types";
import { blogPosts } from "../../../stores";
import { get } from "svelte/store";
export const load = (async ({ params, fetch }) => {
const data = await fetchGhost("posts/slug/" + params.title);
// yes this was made by gitbub copilot
const allPosts = get(blogPosts);
const meta = {
title: !allPosts.error ? data.posts[0].title : ""
};
const load: PageServerLoad = async ({ params }: PageServerLoadEvent) => {
const allPosts = get(blogPosts) as { error?: boolean; posts?: any[] };
let post: any = {};
let title = "";
if (allPosts && !allPosts.error && Array.isArray(allPosts.posts)) {
post = allPosts.posts.find((p: any) => p.slug === params.title) || {};
title = post.title || "";
}
return {
post,
allPosts,
title
};
};
return {
post: !allPosts.error ? data.posts[0] : {},
allPosts: allPosts,
...meta
};
}) satisfies PageServerLoad;
export { load };