refactor: replace postSlug with Astro content slug

* refactor: replace postSlug with Astro content slug

Remove postSlug from blog schema. Refactor articles that use postSlug. Remove slugify function from slugify util file. Replace slugify logic with Astro's content collections slug logic.

Closes: #186

* docs: update docs for removed slugify contents

* refactor: remove unused import
This commit is contained in:
Sat Naing
2023-12-27 10:20:55 +06:30
committed by GitHub
parent 80e67a1dca
commit 2827d4e7d8
22 changed files with 43 additions and 50 deletions
+5 -6
View File
@@ -8,7 +8,6 @@ import Hr from "@components/Hr.astro";
import Card from "@components/Card";
import Socials from "@components/Socials.astro";
import getSortedPosts from "@utils/getSortedPosts";
import slugify from "@utils/slugify";
import { SOCIALS } from "@config";
const posts = await getCollection("blog");
@@ -49,7 +48,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
<p>
Read the blog posts or check
<LinkButton
className="hover:text-skin-accent underline underline-offset-4 decoration-dashed"
className="underline decoration-dashed underline-offset-4 hover:text-skin-accent"
href="https://github.com/satnaing/astro-paper#readme"
>
README
@@ -74,9 +73,9 @@ const socialCount = SOCIALS.filter(social => social.active).length;
<section id="featured">
<h2>Featured</h2>
<ul>
{featuredPosts.map(({ data }) => (
{featuredPosts.map(({ data, slug }) => (
<Card
href={`/posts/${slugify(data)}`}
href={`/posts/${slug}`}
frontmatter={data}
secHeading={false}
/>
@@ -95,10 +94,10 @@ const socialCount = SOCIALS.filter(social => social.active).length;
sortedPosts
.filter(({ data }) => !data.featured)
.map(
({ data }, index) =>
({ data, slug }, index) =>
index < 4 && (
<Card
href={`/posts/${slugify(data)}`}
href={`/posts/${slug}`}
frontmatter={data}
secHeading={false}
/>