diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index edf35d7..e3d3150 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -21,7 +21,7 @@ const title = Astro.props.frontmatter - {title} + {`ghall.blog - ${title}`}
diff --git a/src/pages/404.md b/src/pages/404.md new file mode 100644 index 0000000..173af13 --- /dev/null +++ b/src/pages/404.md @@ -0,0 +1,10 @@ +--- +layout: ../layouts/Layout.astro +title: "About" +--- + +## 404 - Page not found! + +You're trying to find a page that does not exist. + +[Click here](/) to find your way home. diff --git a/src/pages/index.astro b/src/pages/index.astro index d7147c4..667b622 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -15,24 +15,28 @@ const response = await fetch( const posts = await response.json(); --- - -
- { - posts.objects.map((post) => ( -
- {post.thumbnail ? ( -
- {`Thumbnail -
- ) : null} -
- - ${post.content.split("

")[0]}`} /> - Read More + + { + posts.objects.map((post) => ( +
+ {post.thumbnail ? ( +
+ {`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();