- {
- posts.objects.map((post) => (
-
- {post.thumbnail ? (
-
-

-
- ) : null}
-
-
-
${post.content.split("")[0]}`} />
- Read More
+
+ {
+ posts.objects.map((post) => (
+
+ {post.thumbnail ? (
+
+
-
- ))
- }
- {posts.objects.length < 5 ? null : More Posts}
-
+ ) : null}
+
+
+
${post.content.split("")[0]}`} />
+ Read More
+
+
+ ))
+ }
+ {posts.objects.length < 5 ? null :
All Posts}
+
+
diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro
index 8ecae6d..a922762 100644
--- a/src/pages/posts/[slug].astro
+++ b/src/pages/posts/[slug].astro
@@ -7,15 +7,18 @@ import BlogHeader from "../../components/BlogHeader.astro";
const { slug } = Astro.params;
+console.log(`SLUG: ${slug}`);
+
const response = await fetch(
`https://api.cosmicjs.com/v2/buckets/${
import.meta.env.BUCKET_SLUG
}/objects?pretty=true&query=%7B%22type%22%3A%22blog-posts%22%7D&read_key=${
import.meta.env.BUCKET_READ_KEY
- }&limit=20&slug=${slug}`
+ }&limit=5&query=%7B%22slug%22%3A%7B%22%24eq%22%3A%22${slug}%22%7D%7D`
);
const posts = await response.json();
+
const post = posts.objects[0];
---
diff --git a/src/pages/archive.astro b/src/pages/posts/index.astro
similarity index 88%
rename from src/pages/archive.astro
rename to src/pages/posts/index.astro
index 615b147..7078548 100644
--- a/src/pages/archive.astro
+++ b/src/pages/posts/index.astro
@@ -1,13 +1,13 @@
---
import { format } from "date-fns";
-import Layout from "../layouts/Layout.astro";
+import Layout from "../../layouts/Layout.astro";
const response = await fetch(
`https://api.cosmicjs.com/v2/buckets/${
import.meta.env.BUCKET_SLUG
}/objects?pretty=true&query=%7B%22type%22%3A%22blog-posts%22%7D&read_key=${
import.meta.env.BUCKET_READ_KEY
- }&skip=5&limit=25`
+ }&limit=25`
);
const posts = await response.json();