From b38b2857b5f74e2d01a3c6f9a702b953f6f326cf Mon Sep 17 00:00:00 2001 From: Mamadou Diagne Date: Mon, 8 Apr 2024 00:13:13 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor=20(pages):=20upda?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/about.md | 2 +- .../categories/[categorie]/[posts]/[...slug].astro | 5 ++++- src/pages/posts/[...slug].astro | 5 ++++- src/pages/tag/[tag]/[posts]/[...slug].astro | 13 +++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/about.md b/src/pages/about.md index b3e0c3c..d99d2f4 100644 --- a/src/pages/about.md +++ b/src/pages/about.md @@ -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 diff --git a/src/pages/categories/[categorie]/[posts]/[...slug].astro b/src/pages/categories/[categorie]/[posts]/[...slug].astro index 1ac052d..622181c 100644 --- a/src/pages/categories/[categorie]/[posts]/[...slug].astro +++ b/src/pages/categories/[categorie]/[posts]/[...slug].astro @@ -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); @@ -25,4 +26,6 @@ const { entry } = Astro.props; const { Content } = await entry.render(); --- - + + + diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index 39eeeee..ec790f4 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -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); @@ -14,4 +15,6 @@ const { entry } = Astro.props; const { Content } = await entry.render(); --- - + + + diff --git a/src/pages/tag/[tag]/[posts]/[...slug].astro b/src/pages/tag/[tag]/[posts]/[...slug].astro index e29601c..90b1b48 100644 --- a/src/pages/tag/[tag]/[posts]/[...slug].astro +++ b/src/pages/tag/[tag]/[posts]/[...slug].astro @@ -2,6 +2,8 @@ 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); @@ -9,11 +11,12 @@ export async function getStaticPaths() { 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 }, })); @@ -25,4 +28,6 @@ const { entry } = Astro.props; const { Content } = await entry.render(); --- - + + +