-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
have dedicated files for blog entries
- Loading branch information
Showing
6 changed files
with
97 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function BlogEntries({ blogentries }) { | ||
const entries = blogentries | ||
.sort((a, b) => b.data.date - a.data.date); | ||
return ( | ||
<div> | ||
<ul> | ||
{( | ||
<div id="blogentries"> | ||
{entries.map((blogentry, idx) => { | ||
return ( | ||
<li key={idx} className={"d-flex justify-content-center mt-5"}> | ||
<a | ||
href={`/blogentries/${blogentry.slug}`} | ||
key={`${blogentry.id}_${idx}`} | ||
> | ||
<h3>{blogentry.data.title}</h3> | ||
<div> | ||
<time>{blogentry.data.date.toLocaleDateString()}</time> | ||
</div> | ||
</a> | ||
</li> | ||
); | ||
})} | ||
</div> | ||
)} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export default BlogEntries; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
import PageLayout from "../layouts/PageLayout.astro"; | ||
import BlogEntries from "../components/blogEntries.jsx"; | ||
import { getCollection } from "astro:content"; | ||
const blogentries = await getCollection("blogentries"); | ||
--- | ||
|
||
<PageLayout | ||
title="Blog" | ||
backgroundImage="/images/blog-header.jpg" | ||
mainTitle="Blog" | ||
containerClass="container-fluid" | ||
> | ||
<BlogEntries client:load blogentries={blogentries} /> | ||
</PageLayout> | ||
|
||
<style lang="sass" is:global> | ||
img | ||
max-width: 80pc | ||
margin: 2rem | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
import { getCollection } from "astro:content"; | ||
import PageLayout from "../../layouts/PageLayout.astro"; | ||
import LocalTime from "../../components/LocalTime.jsx"; | ||
export async function getStaticPaths() { | ||
const blogEntries = await getCollection("blogentries"); | ||
return blogEntries.map((entry) => ({ | ||
params: { slug: entry.slug }, | ||
props: { entry }, | ||
})); | ||
} | ||
const { entry } = Astro.props; | ||
const { Content } = await entry.render(); | ||
const { | ||
title, | ||
date, | ||
} = entry.data; | ||
--- | ||
|
||
<PageLayout | ||
backgroundImage="/images/blog-header.jpg" | ||
title={title} | ||
mainTitle={title} | ||
> | ||
<Content /> | ||
</PageLayout> | ||
|
||
<style is:global> | ||
img { | ||
margin: 0.5rem auto; | ||
width: 100%; | ||
max-width: 960px; | ||
} | ||
</style> |