From f497bc20ef6920ecb40c40d51ee4f2383fdbe368 Mon Sep 17 00:00:00 2001 From: Korbs Date: Wed, 20 Nov 2024 20:09:56 -0500 Subject: [PATCH] Prepare switch to Ghost --- astro.config.mjs | 7 +- src/components/blog/posts.astro | 56 ----------- .../blog/{[slug].astro => [...slug].astro} | 41 ++++---- src/pages/blog/index.astro | 95 ++++++++++++++++--- src/pages/index.astro | 76 ++++++++++++++- 5 files changed, 179 insertions(+), 96 deletions(-) rename src/pages/blog/{[slug].astro => [...slug].astro} (60%) diff --git a/astro.config.mjs b/astro.config.mjs index 48efd04..72337a1 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,7 +10,10 @@ export default defineConfig({ // Slug issue if not enabled redirects: { '/docs/': '/docs/zorn/introduction/', - '/docs/minpluto': '/docs/zorn/introduction/' // ? + '/docs/minpluto': '/docs/zorn/introduction/', + '/blog/minpluto-and-its-future-goals': '/blog/673e823bd79b8500015f4763', + '/blog/zen-browser-worth-the-hype': '/blog/673e81f4d79b8500015f4755', + '/blog/desktop-development-stops': '/blog/673e817fd79b8500015f474a', }, integrations: [markdoc(), mdx(), betterImageService({ @@ -71,7 +74,7 @@ export default defineConfig({ disallow: '/' }] }), vue()], - output: 'static', + output: 'server', server: { port: 2014, host: true diff --git a/src/components/blog/posts.astro b/src/components/blog/posts.astro index 1d47ec8..a6ae105 100644 --- a/src/components/blog/posts.astro +++ b/src/components/blog/posts.astro @@ -45,59 +45,3 @@ if (Astro.url.pathname = '/blog/recommended-reading/') { )) } - - - diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[...slug].astro similarity index 60% rename from src/pages/blog/[slug].astro rename to src/pages/blog/[...slug].astro index f07c521..3c4f834 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[...slug].astro @@ -1,37 +1,35 @@ --- +// Layout +import Default from "@layouts/Default.astro"; + +// Components +import Hero from "@components/Hero.astro"; +import Heading from "@components/Heading.astro"; +import Posts from "@components/blog/posts.astro"; +import LargeCard from "@components/Feature.astro"; +import {Zorn} from "@minpluto/zorn" + // Icons import { Calendar } from "@iconoir/vue"; -// Get Colletion and Slug -import { getCollection, getEntry } from "astro:content"; -import Default from "@layouts/Default.astro"; - -const { slug } = Astro.params; -if (!slug) throw new Error("Slug not found"); -const post = await getEntry("posts", slug); - -if (!post) throw new Error("No post found for this slug"); -const { Content } = await post.render(); - -/// Generate static pages -export async function getStaticPaths() { - const posts = await getCollection("posts"); - return posts.map((post) => ({ params: { slug: post.slug } })); -} -export const prerender = true; +const Id = Astro.url.href.split("/blog/").pop(); +const GhostPostFetch = 'https://blog.ghost.sudovanilla.org/ghost/api/content/posts/' + Id + '/?key=bef2ed15d9e38f7703be9412b3' +const GhostPostResponse = await fetch(GhostPostFetch); +const GhostPost = await GhostPostResponse.json(); --- +
- -

{post.data.title}

+ +

{GhostPost.posts[0].title}

- {new Date(post.data.date).toLocaleDateString()} + {new Date(GhostPost.posts[0].published_at).toLocaleDateString()}

- +
@@ -83,6 +81,7 @@ export const prerender = true; display: block; width: 100% !important; max-width: 100% !important; + height: fit-content; } } diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 23a631d..4df69f1 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -1,22 +1,91 @@ --- // Layout -import Default from "@layouts/Default.astro" +import Default from "@layouts/Default.astro"; // Components -import Posts from "@components/blog/posts.astro" +import Hero from "@components/Hero.astro"; +import Heading from "@components/Heading.astro"; +import Posts from "@components/blog/posts.astro"; +import LargeCard from "@components/Feature.astro"; +import {Zorn} from "@minpluto/zorn" // List Posts -import { getCollection } from "astro:content" -const posts = await getCollection("posts") +const GhostFetch = 'https://blog.ghost.sudovanilla.org/ghost/api/content/posts/?key=bef2ed15d9e38f7703be9412b3' +const GhostResponse = await fetch(GhostFetch); +const Ghost = await GhostResponse.json(); + +// Icons +import { BookmarkBook, ReportColumns } from "@iconoir/vue"; --- - - -

SudoVanilla Blog

- -
- + + + + + + \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 47e7410..9e62450 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -10,8 +10,9 @@ import LargeCard from "@components/Feature.astro"; import {Zorn} from "@minpluto/zorn" // List Posts -import { getCollection } from "astro:content"; -const posts = await getCollection("posts"); +const GhostFetch = 'https://blog.ghost.sudovanilla.org/ghost/api/content/posts/?key=bef2ed15d9e38f7703be9412b3' +const GhostResponse = await fetch(GhostFetch); +const Ghost = await GhostResponse.json(); // Icons import { BookmarkBook, ReportColumns } from "@iconoir/vue"; @@ -31,7 +32,18 @@ import { BookmarkBook, ReportColumns } from "@iconoir/vue"; - + @@ -78,4 +90,60 @@ import { BookmarkBook, ReportColumns } from "@iconoir/vue"; CTA_Primary_Link="/docs/penpot-desktop/introduction/" /> -
\ No newline at end of file + + + + \ No newline at end of file