Skip to content

Commit

Permalink
feat: improve tags and levels
Browse files Browse the repository at this point in the history
  • Loading branch information
andyluss committed Jul 10, 2024
1 parent 56c8834 commit 420ae65
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pages/blog/filter/[filter].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import { getAll } from "../../../utils/content";
import IndexLayout from "../../../layouts/IndexLayout.astro";
export async function getStaticPaths() {
const { tags, levels } = await getAll("blog");
return levels
.map((level) =>
tags.map((tag) => ({ params: { filter: `${level[0]}-${tag[0]}` } })),
)
.flat();
}
const { filter } = Astro.params;
const [levelStr, tag] = filter.split("-");
const level = levelStr === "All" ? "All" : Number(levelStr);
---

<IndexLayout collection="blog" {tag} {level} />
19 changes: 19 additions & 0 deletions src/pages/dev/filter/[filter].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import { getAll } from "../../../utils/content";
import IndexLayout from "../../../layouts/IndexLayout.astro";
export async function getStaticPaths() {
const { tags, levels } = await getAll("dev");
return levels
.map((level) =>
tags.map((tag) => ({ params: { filter: `${level[0]}-${tag[0]}` } })),
)
.flat();
}
const { filter } = Astro.params;
const [levelStr, tag] = filter.split("-");
const level = levelStr === "All" ? "All" : Number(levelStr);
---

<IndexLayout collection="dev" {tag} {level} />

0 comments on commit 420ae65

Please sign in to comment.