blog posts archive page

Changed files
+73
src
+12
src/components/BlogPost.astro
··· 14 14 display: block; 15 15 border: 10px double; 16 16 text-decoration: none; 17 + margin-bottom: 13px; 18 + } 19 + 20 + a:last-child { 21 + margin-bottom: 0; 17 22 } 18 23 19 24 article { 20 25 padding: 13px 15px; 26 + overflow: hidden; 27 + } 28 + 29 + article h3 { 30 + white-space: nowrap; 31 + overflow: hidden; 32 + text-overflow: ellipsis; 21 33 } 22 34 23 35 time {
+23
src/layouts/SinglePage.astro
··· 1 + --- 2 + import "../styles/main.css"; 3 + import Toolbar from "../components/Toolbar.astro"; 4 + 5 + const { backlink } = Astro.props; 6 + --- 7 + 8 + <Toolbar {backlink} /> 9 + <div class="wrapper bwcontainer"> 10 + <header class="bwbox"> 11 + <slot name="header" /> 12 + </header> 13 + <main class="bwbox"> 14 + <slot /> 15 + </main> 16 + </div> 17 + 18 + <style> 19 + .wrapper { 20 + max-width: 82ch; 21 + margin: 0 auto; 22 + } 23 + </style>
+33
src/pages/blog.astro
··· 1 + --- 2 + import { getCollection } from "astro:content"; 3 + import Base from "../components/Base.astro"; 4 + import SinglePage from "../layouts/SinglePage.astro"; 5 + import BlogPost from "../components/BlogPost.astro"; 6 + 7 + const post = await getCollection("blog").then((x) => 8 + x.sort( 9 + (a, b) => 10 + (b.data.pub as unknown as number) - (a.data.pub as unknown as number), 11 + ), 12 + ); 13 + --- 14 + 15 + <Base 16 + title="BLOG" 17 + graph={{ 18 + description: "Blog posts and such.", 19 + }} 20 + > 21 + <SinglePage> 22 + <h1 slot="header" class="center">Blog posts</h1> 23 + { 24 + post.map((post) => ( 25 + <BlogPost 26 + url={`/blog/${post.id}`} 27 + title={post.data.title} 28 + time={`${post.data.pub.getFullYear()}-${post.data.pub.getMonth() + 1}-${post.data.pub.getDate()}`} 29 + /> 30 + )) 31 + } 32 + </SinglePage> 33 + </Base>
+1
src/pages/home.astro
··· 36 36 title={post[0].data.title} 37 37 time={`${post[0].data.pub.getFullYear()}-${post[0].data.pub.getMonth() + 1}-${post[0].data.pub.getDate()}`} 38 38 /> 39 + <a href="/blog">View all posts</a> 39 40 </div> 40 41 </main> 41 42 </div>
+4
src/styles/main.css
··· 29 29 font-size: 1.5rem; 30 30 } 31 31 32 + h3 { 33 + font-size: 1.25rem; 34 + } 35 + 32 36 p, 33 37 li { 34 38 font-size: 1rem;