mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
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:
@@ -1,13 +1,13 @@
|
||||
import Fuse from "fuse.js";
|
||||
import { useEffect, useRef, useState, useMemo } from "react";
|
||||
import Card from "@components/Card";
|
||||
import slugify from "@utils/slugify";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
|
||||
export type SearchItem = {
|
||||
title: string;
|
||||
description: string;
|
||||
data: CollectionEntry<"blog">["data"];
|
||||
slug: string;
|
||||
};
|
||||
|
||||
interface Props {
|
||||
@@ -111,9 +111,9 @@ export default function SearchBar({ searchList }: Props) {
|
||||
{searchResults &&
|
||||
searchResults.map(({ item, refIndex }) => (
|
||||
<Card
|
||||
href={`/posts/${slugify(item.data)}`}
|
||||
href={`/posts/${item.slug}`}
|
||||
frontmatter={item.data}
|
||||
key={`${refIndex}-${slugify(item.data)}`}
|
||||
key={`${refIndex}-${item.slug}`}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user