cosmicjs to markdown
This commit is contained in:
+11
-22
@@ -1,37 +1,26 @@
|
||||
---
|
||||
import { Markup } from "astro-remote";
|
||||
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
import BlogHeader from "../components/BlogHeader.astro";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import BlogHeader from "@components/BlogHeader.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
|
||||
}&limit=5`
|
||||
);
|
||||
|
||||
const posts = await response.json();
|
||||
const posts = await Astro.glob("./posts/*.md");
|
||||
---
|
||||
|
||||
<Layout title="Home">
|
||||
{
|
||||
posts.objects.map((post) => (
|
||||
posts.map((post) => (
|
||||
<article class="post-preview">
|
||||
<div>
|
||||
<BlogHeader title={post.title} date={post.published_at} />
|
||||
<Markup content={`<p>${post.content.split("</p>")[0]}`} />
|
||||
<a href={`/posts/${post.slug}`}>Read More</a>
|
||||
<BlogHeader
|
||||
title={post.frontmatter.title}
|
||||
date={post.frontmatter.pubDate}
|
||||
/>
|
||||
<Markup content={`<p>${post.compiledContent().split("</p>")[0]}`} />
|
||||
<a href={post.url}>Read More</a>
|
||||
</div>
|
||||
</article>
|
||||
))
|
||||
}
|
||||
{posts.objects.length < 5 ? null : <a href="/posts">All Posts</a>}
|
||||
{posts.length < 5 ? null : <a href="/archive">All Posts</a>}
|
||||
</Layout>
|
||||
|
||||
<!-- <style>
|
||||
blog-post {
|
||||
article
|
||||
}
|
||||
</style> -->
|
||||
|
||||
Reference in New Issue
Block a user