mirror of
https://github.com/rjNemo/orbital-orbit
synced 2026-06-12 18:06:38 +00:00
feat: use dynamic routes with props
This commit is contained in:
parent
461c059480
commit
6d488d8307
2 changed files with 28 additions and 3 deletions
|
|
@ -7,9 +7,7 @@ author: Ruidy
|
||||||
image:
|
image:
|
||||||
url: "https://docs.astro.build/assets/rose.webp"
|
url: "https://docs.astro.build/assets/rose.webp"
|
||||||
alt: "The Astro logo on a dark background with a pink glow."
|
alt: "The Astro logo on a dark background with a pink glow."
|
||||||
tags:
|
tags: ["astro", "blogging", "learning in public"]
|
||||||
- astro
|
|
||||||
- blog
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Welcome to my _new blog_ about learning Astro! Here, I will share my learning journey
|
Welcome to my _new blog_ about learning Astro! Here, I will share my learning journey
|
||||||
|
|
|
||||||
27
src/pages/tags/[tag].astro
Normal file
27
src/pages/tags/[tag].astro
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
import BLogPost from "../../components/BLogPost.astro";
|
||||||
|
import BaseLayout from "../../layouts/BaseLayout.astro"
|
||||||
|
|
||||||
|
export async function getStaticPaths() {
|
||||||
|
const posts = Object.values(import.meta.glob('../posts/*.md', { eager: true }));
|
||||||
|
return [
|
||||||
|
{params: {tag: "astro"}, props: {posts }},
|
||||||
|
{ params: { tag: "successes" }, props:{ posts} },
|
||||||
|
{ params: { tag: "community" } , props:{ posts} },
|
||||||
|
{ params: { tag: "blogging" }, props:{ posts} },
|
||||||
|
{ params: { tag: "setbacks" }, props:{ posts} },
|
||||||
|
{ params: { tag: "learning in public" }, props:{ posts} },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const { tag } = Astro.params
|
||||||
|
const { posts } = Astro.props
|
||||||
|
const filteredPosts = posts.filter((post:any) => post.frontmatter.tags?.includes(tag))
|
||||||
|
---
|
||||||
|
|
||||||
|
<BaseLayout pageTitle={`Posts tagged with ${tag}`}>
|
||||||
|
<p>Posts tagged with {tag}</p>
|
||||||
|
<ul>
|
||||||
|
{filteredPosts.map((post:any )=> <BLogPost url={post.url} title={post.frontmatter.title}/>)}
|
||||||
|
</ul>
|
||||||
|
</BaseLayout>
|
||||||
Loading…
Reference in a new issue