Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit 532e93a

Browse files
fix the type and rewrite it
1 parent 1910524 commit 532e93a

File tree

1 file changed

+31
-26
lines changed
  • packages/section-blog-theme/components/Layouts

1 file changed

+31
-26
lines changed
Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import type { PageOpts, ThemeConfig } from "nextra";
2-
import { useRouter } from "next/router";
1+
import type { PageOpts } from "nextra";
32
import { useTagContent } from "@/utility/useTagContent"
43
import { ArticleCard } from "@/components/Card/Card";
54
import dayjs from "dayjs";
65
import { Article } from "@/components/Article/Article";
76
import { Error404 } from "./404";
87
import { TypeSectionBlogTheme } from "@/src/types"
8+
import type {ReactNode} from "react";
9+
import { useRouter } from 'next/router'
910

10-
export function Tag({ pageOpts, themeConfig, children }: { pageOpts: PageOpts; themeConfig: TypeSectionBlogTheme; children: React.ReactNode; }) {
11+
12+
export function Tag({ pageOpts, themeConfig, children }: { pageOpts: PageOpts; themeConfig: TypeSectionBlogTheme; children: ReactNode; }) {
1113

1214
const { DateFormat } = themeConfig;
1315

@@ -16,33 +18,36 @@ export function Tag({ pageOpts, themeConfig, children }: { pageOpts: PageOpts; t
1618
let tagSlug = router.query && router.query.tag && typeof router.query.tag === "string" ? router.query.tag : router?.query?.tag as string
1719

1820
const { posts } = useTagContent(pageOpts, tagSlug)
19-
20-
if ( posts === undefined || posts.length === 0) {
21-
return (<Error404 /> )
21+
22+
if (posts === undefined || posts.length === 0) {
23+
return (<Error404 />)
2224
}
2325
return (
2426
<>
2527
<Article>{children}</Article>
26-
<div className="mx-auto my-24 divide-y divide-slate-700 grid-cols-1 grid max-w-[724px] lg:max-w-[1024px] gap-4">
27-
{posts?.map(
28-
(post) => {
29-
30-
let getDate = dayjs(post.frontMatter.date).format(DateFormat? DateFormat : "MMM DD, YYYY");
31-
32-
return (
33-
<ArticleCard
34-
key={post.frontMatter.date + post.frontMatter.title}
35-
title={post.frontMatter.title}
36-
description={post.frontMatter.description}
37-
tag={post.frontMatter.tags}
38-
date={getDate}
39-
URL={post.route}
40-
author={post.frontMatter?.author}
41-
/>
42-
);
43-
},
44-
)}
45-
</div>
28+
29+
<section className="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6">
30+
<div className="grid gap-8 lg:grid-cols-2">
31+
{posts?.map(
32+
(post) => {
33+
34+
let getDate = dayjs(post.frontMatter.date).format(DateFormat ? DateFormat : "MMM DD, YYYY");
35+
36+
return (
37+
<ArticleCard
38+
key={post.frontMatter.date + post.frontMatter.title}
39+
title={post.frontMatter.title}
40+
description={post.frontMatter.description}
41+
tag={post.frontMatter.tags}
42+
date={getDate}
43+
URL={post.route}
44+
author={post.frontMatter?.author}
45+
/>
46+
);
47+
},
48+
)}
49+
</div>
50+
</section>
4651
</>
4752
);
4853
}

0 commit comments

Comments
 (0)