mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +08:00
Update slug url with new function's slugified url
This commit is contained in:
@@ -8,6 +8,7 @@ import Card from "@components/Card";
|
|||||||
import LinkButton from "@components/LinkButton.astro";
|
import LinkButton from "@components/LinkButton.astro";
|
||||||
import type { MarkdownInstance } from "astro";
|
import type { MarkdownInstance } from "astro";
|
||||||
import type { Frontmatter } from "src/types";
|
import type { Frontmatter } from "src/types";
|
||||||
|
import slugify from "@utils/slugify";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
pageNum: number;
|
pageNum: number;
|
||||||
@@ -28,7 +29,7 @@ const next = pageNum < totalPages ? "" : "disabled";
|
|||||||
{
|
{
|
||||||
posts.map(({ frontmatter }) => {
|
posts.map(({ frontmatter }) => {
|
||||||
return (
|
return (
|
||||||
<Card href={`/posts/${frontmatter.slug}`} post={frontmatter} />
|
<Card href={`/posts/${slugify(frontmatter)}`} post={frontmatter} />
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
import { SOCIALS } from "src/config";
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
import Header from "@components/Header.astro";
|
import Header from "@components/Header.astro";
|
||||||
import Footer from "@components/Footer.astro";
|
import Footer from "@components/Footer.astro";
|
||||||
@@ -6,8 +7,8 @@ import LinkButton from "@components/LinkButton.astro";
|
|||||||
import Hr from "@components/Hr.astro";
|
import Hr from "@components/Hr.astro";
|
||||||
import Card from "@components/Card";
|
import Card from "@components/Card";
|
||||||
import getSortedPosts from "@utils/getSortedPosts";
|
import getSortedPosts from "@utils/getSortedPosts";
|
||||||
import { SOCIALS } from "src/config";
|
|
||||||
import socialIcons from "@assets/socialIcons";
|
import socialIcons from "@assets/socialIcons";
|
||||||
|
import slugify from "@utils/slugify";
|
||||||
import type { Frontmatter } from "src/types";
|
import type { Frontmatter } from "src/types";
|
||||||
|
|
||||||
const posts = await Astro.glob<Frontmatter>("../contents/*.md");
|
const posts = await Astro.glob<Frontmatter>("../contents/*.md");
|
||||||
@@ -70,7 +71,7 @@ const sortedPosts = getSortedPosts(posts);
|
|||||||
({ frontmatter }) =>
|
({ frontmatter }) =>
|
||||||
frontmatter.featured && (
|
frontmatter.featured && (
|
||||||
<Card
|
<Card
|
||||||
href={`/posts/${frontmatter.slug}`}
|
href={`/posts/${slugify(frontmatter)}`}
|
||||||
post={frontmatter}
|
post={frontmatter}
|
||||||
secHeading={false}
|
secHeading={false}
|
||||||
/>
|
/>
|
||||||
@@ -90,7 +91,7 @@ const sortedPosts = getSortedPosts(posts);
|
|||||||
({ frontmatter }, index) =>
|
({ frontmatter }, index) =>
|
||||||
index < 4 && (
|
index < 4 && (
|
||||||
<Card
|
<Card
|
||||||
href={`/posts/${frontmatter.slug}`}
|
href={`/posts/${slugify(frontmatter)}`}
|
||||||
post={frontmatter}
|
post={frontmatter}
|
||||||
secHeading={false}
|
secHeading={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import getSortedPosts from "@utils/getSortedPosts";
|
|||||||
import getPageNumbers from "@utils/getPageNumbers";
|
import getPageNumbers from "@utils/getPageNumbers";
|
||||||
import type { MarkdownInstance } from "astro";
|
import type { MarkdownInstance } from "astro";
|
||||||
import type { Frontmatter } from "src/types";
|
import type { Frontmatter } from "src/types";
|
||||||
|
import slugify from "@utils/slugify";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
post: MarkdownInstance<Frontmatter>;
|
post: MarkdownInstance<Frontmatter>;
|
||||||
@@ -27,12 +28,12 @@ type PagePaths = {
|
|||||||
}[];
|
}[];
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts = await Astro.glob("../../contents/*.md");
|
const posts = await Astro.glob<Frontmatter>("../../contents/*.md");
|
||||||
|
|
||||||
let postResult: PostResult = posts.map((post) => {
|
let postResult: PostResult = posts.map((post) => {
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
slug: post.frontmatter.slug,
|
slug: slugify(post.frontmatter),
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
post,
|
post,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import getUniqueTags from "@utils/getUniqueTags";
|
|||||||
import getPostsByTag from "@utils/getPostsByTag";
|
import getPostsByTag from "@utils/getPostsByTag";
|
||||||
import type { MarkdownInstance } from "astro";
|
import type { MarkdownInstance } from "astro";
|
||||||
import type { Frontmatter } from "src/types";
|
import type { Frontmatter } from "src/types";
|
||||||
|
import slugify from "@utils/slugify";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
post: MarkdownInstance<Frontmatter>;
|
post: MarkdownInstance<Frontmatter>;
|
||||||
@@ -52,7 +53,7 @@ const tagPosts = getPostsByTag(posts, tag);
|
|||||||
<ul>
|
<ul>
|
||||||
{
|
{
|
||||||
tagPosts.map(({ frontmatter }) => (
|
tagPosts.map(({ frontmatter }) => (
|
||||||
<Card href={`/posts/${frontmatter.slug}`} post={frontmatter} />
|
<Card href={`/posts/${slugify(frontmatter)}`} post={frontmatter} />
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user