File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 </a >
1919 <p class ="text-gray-600 dark:text-gray-400" >{post .frontmatter .description }</p >
2020 <ul class =" flex flex-wrap" >
21+ <li class ="mr-3 text-gray-400 dark:text-gray-600 text-sm" >{post .readingTime } min read</li >
2122 {#each post .frontmatter .tags as tag }
2223 <li class ="mr-3 text-gray-400 dark:text-gray-600 text-sm font-medium hover:underline" ><a href ={` /tags/${tag } ` }>{` #${tag } ` }</a ></li >
2324 {/each }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ ---
2+ import BlogPostCard from " ../../components/BlogPostCard.svelte" ;
3+ import Navbar from " ../../components/Navbar.svelte" ;
4+ import BaseLayout from " ../../layouts/BaseLayout.astro" ;
5+ const allPosts = await Astro .glob (" ./*.md" );
6+ const nonDraftPosts = allPosts .filter ((post ) => ! post .frontmatter .draft );
7+ const orderedPosts = nonDraftPosts .sort ((a , b ) => {
8+ const aDate = new Date (a .frontmatter .pubDate );
9+ const bDate = new Date (b .frontmatter .pubDate );
10+ return bDate .valueOf () - aDate .valueOf ();
11+ });
12+ const postsWithReadingTime = orderedPosts .map ((post ) => {
13+ const wordCount = post .rawContent ().split (" " ).length ;
14+ const readingTime = Math .ceil (wordCount / 200 );
15+ return {
16+ ... post ,
17+ readingTime ,
18+ };
19+ });
20+ ---
21+
22+ <BaseLayout title =" Milán Herke - Blog" >
23+ <Navbar />
24+ { postsWithReadingTime .map ((post ) => <BlogPostCard post = { post } />)}
25+ </BaseLayout >
You can’t perform that action at this time.
0 commit comments