Skip to content

Commit

Permalink
♻️ refactor (pages): update
Browse files Browse the repository at this point in the history
  • Loading branch information
dofbi committed Apr 8, 2024
1 parent 2a9f6aa commit b38b285
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "About"
date: 2024-04-06T06:51:00Z
slug: "about"
description: "simple blog is a simple blog theme for Astro. It is a fork of the simple blog theme for Hugo."
layout: "../layouts/PostLayout.astro"
layout: "../layouts/AboutLayout.astro"
---

# Astro Simple blog theme
Expand Down
5 changes: 4 additions & 1 deletion src/pages/categories/[categorie]/[posts]/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import config from "@config/config.json";
import { getContent } from "@lib/contentParser.astro";
import { getCategories } from "@lib/categoriesParser.astro";
import MarkdownPostLayout from "../../../../layouts/PostLayout.astro";
export async function getStaticPaths() {
const allCategories = await getCategories(config.settings.blog_folder);
Expand All @@ -25,4 +26,6 @@ const { entry } = Astro.props;
const { Content } = await entry.render();
---

<Content />
<MarkdownPostLayout frontmatter={entry}>
<Content />
</MarkdownPostLayout>
5 changes: 4 additions & 1 deletion src/pages/posts/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import config from "@config/config.json";
import { getContent } from "@lib/contentParser.astro";
import MarkdownPostLayout from "../../layouts/PostLayout.astro";
export async function getStaticPaths() {
const posts = await getContent(config.settings.blog_folder);
Expand All @@ -14,4 +15,6 @@ const { entry } = Astro.props;
const { Content } = await entry.render();
---

<Content />
<MarkdownPostLayout frontmatter={entry}>
<Content />
</MarkdownPostLayout>
13 changes: 9 additions & 4 deletions src/pages/tag/[tag]/[posts]/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
import config from "@config/config.json";
import { getContent } from "@lib/contentParser.astro";
import { getTags } from "@lib/tagsParser.astro";
import { addAdjacentSlugs } from "@lib/utils/addAdjacentSlugs";
import MarkdownPostLayout from "../../../../layouts/PostLayout.astro";
export async function getStaticPaths() {
const allTags = await getTags(config.settings.blog_folder);
const allposts = await getContent(config.settings.blog_folder);
const paths = allTags.flatMap((tag) => {
const filteredPosts = allposts.filter(
(posts: any) =>
posts.data.tags && posts.data.tags.includes(tag)
(posts: any) => posts.data.tags && posts.data.tags.includes(tag)
);
return filteredPosts.map((entry: any) => ({
const postsWithAdjacentSlugs = addAdjacentSlugs(filteredPosts, `/tag/${tag}`);
return postsWithAdjacentSlugs.map((entry: any) => ({
params: { tag: tag, posts: entry.slug },
props: { entry },
}));
Expand All @@ -25,4 +28,6 @@ const { entry } = Astro.props;
const { Content } = await entry.render();
---

<Content />
<MarkdownPostLayout frontmatter={entry}>
<Content />
</MarkdownPostLayout>

0 comments on commit b38b285

Please sign in to comment.