File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ const { url, title } = Astro .props ;
3+ ---
4+
5+ <li ><a href ={ url } >{ title } </a ></li >
Original file line number Diff line number Diff line change 1+ ---
2+ import BaseLayout from ' ./BaseLayout.astro' ;
3+ const { frontmatter } = Astro .props ;
4+ ---
5+ <BaseLayout pgTitle ={ frontmatter .title } >
6+ <p >Written by { frontmatter .author } </p >
7+ <p >Published on: { frontmatter .pubDate .toString ().slice (0 ,10 )} </p >
8+ <img src ={ frontmatter .image .url } width =" 300" alt ={ frontmatter .image .alt } />
9+ <slot />
10+ </BaseLayout >
Original file line number Diff line number Diff line change 11---
22import ' ../styles/global.css' ;
33import BaseLayout from ' ../layouts/BaseLayout.astro' ;
4+ import BlogPost from ' ../components/BlogPost.astro' ;
5+
6+ const allPosts = Object .values (import .meta .glob (' ./posts/*.md' , { eager: true }));
47
58const pgTitle = " My Astro Learning Blog" ;
69---
710
811<BaseLayout pgTitle ={ pgTitle } >
912 <p >This is where I will post about my journey learning Astro.</p >
1013 <ul >
11- <a href =" /myAstroTest/posts/post-1" >My first blog post</a >
12- <a href =" /myAstroTest/posts/post-2" >Post 2</a >
13- <a href =" /myAstroTest/posts/post-3" >Post 3</a >
14+ { allPosts .map ((post : any ) => <BlogPost url = { post .url } title = { post .frontmatter .title } />)}
1415 </ul >
1516
1617</BaseLayout >
Original file line number Diff line number Diff line change 11---
2+ layout : ../../layouts/MDpostLayout.astro
23title : ' My First Blog Post'
34pubDate : 2026-04-16
45description : ' This is the first post of my new Astro blog.'
89 alt : ' The Astro logo on a dark background with a pink glow.'
910tags : ["astro", "blogging", "learning in public"]
1011---
11- # My First Blog Post
12-
13- Published on: 2022-07-01
1412
1513Welcome to my _ new blog_ about learning Astro! Here, I will share my learning journey as I build a new website.
1614
Original file line number Diff line number Diff line change 11---
2+ layout : ../../layouts/MDpostLayout.astro
23title : My Second Blog Post
34author : Astro Learner
45description : " After learning some Astro, I couldn't stop!"
Original file line number Diff line number Diff line change 11---
2+ layout : ../../layouts/MDpostLayout.astro
23title : My Third Blog Post
34author : Astro Learner
45description : " I had some challenges, but asking in the community really helped!"
Original file line number Diff line number Diff line change 1+ ---
2+ layout : ../../layouts/MDpostLayout.astro
3+ title : My Fourth Blog Post
4+ author : Astro Learner
5+ description : " This post will show up on its own!"
6+ image :
7+ url : " https://docs.astro.build/default-og-image.png"
8+ alt : " The word astro against an illustration of planets and stars."
9+ pubDate : 2026-04-17
10+ tags : ["astro", "successes"]
11+ ---
12+
13+ This post should show up with my other blog posts, because ` import.meta.glob() ` is returning a list of all my posts in order to create my list.
You can’t perform that action at this time.
0 commit comments