blog routing and about page
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({});
|
export default defineConfig({ output: 'server' });
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 282 KiB |
@@ -5,6 +5,8 @@ title: 'About'
|
|||||||
|
|
||||||
## Hello World!
|
## Hello World!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
My name is Graham Hall, a web developer from Rhode Island.
|
My name is Graham Hall, a web developer from Rhode Island.
|
||||||
|
|
||||||
When I'm not writing code, I'm usually enjoying one of my other hobbies; video games, music, hiking, photography, art, the list goes on...
|
When I'm not writing code, I'm usually enjoying one of my other hobbies; video games, music, hiking, photography, art, the list goes on...
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { Markup } from 'astro-remote';
|
|||||||
|
|
||||||
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}&limit=20&props=slug,title,content`)
|
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=10`)
|
||||||
|
|
||||||
const posts = await response.json();
|
const posts = await response.json();
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -15,8 +16,10 @@ const posts = await response.json();
|
|||||||
<article>
|
<article>
|
||||||
<div style={{display: 'flex', justifyContent: 'space-between'}}>
|
<div style={{display: 'flex', justifyContent: 'space-between'}}>
|
||||||
<h4>{post.title}</h4>
|
<h4>{post.title}</h4>
|
||||||
|
<h5>{`🗓️ ${format(new Date(post.published_at), 'MMM do, y')}`}</h5>
|
||||||
</div>
|
</div>
|
||||||
<Markup content={post.content} />
|
<Markup content={`<p>${post.content.split('</p>')[0]}`} />
|
||||||
|
<a href={`/posts/${post.slug}`}>Read More</a>
|
||||||
</article>
|
</article>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
import { Markup } from 'astro-remote';
|
||||||
|
|
||||||
|
import Layout from '../../layouts/Layout.astro';
|
||||||
|
|
||||||
|
const { slug } = Astro.params;
|
||||||
|
|
||||||
|
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}`)
|
||||||
|
|
||||||
|
const posts = await response.json();
|
||||||
|
const post = posts.objects[0];
|
||||||
|
|
||||||
|
---
|
||||||
|
<Layout title="Blog">
|
||||||
|
<article>
|
||||||
|
<div style={{display: 'flex', justifyContent: 'space-between'}}>
|
||||||
|
<h4>{post.title}</h4>
|
||||||
|
<h5>{`🗓️ ${format(new Date(post.published_at), 'MMM do, y')}`}</h5>
|
||||||
|
</div>
|
||||||
|
<Markup content={post.content} />
|
||||||
|
</article>
|
||||||
|
</Layout>
|
||||||
Reference in New Issue
Block a user