summaryrefslogtreecommitdiff
path: root/src/components/sections
diff options
context:
space:
mode:
authorBertrand Yuan <bert.yuan@outlook.com>2025-12-16 00:15:04 +0800
committerBertrand Yuan <bert.yuan@outlook.com>2025-12-16 00:15:04 +0800
commit785371bb3eccca455e5ce5fccbe9b6e3752a03f6 (patch)
treedd006593448c3500bdcb414af3b4656f7a7683d4 /src/components/sections
parent02ae938c238c9d18448d17a8ec92c0edd8c17463 (diff)
fix(front-end): bug in viewing posts
Diffstat (limited to 'src/components/sections')
-rw-r--r--src/components/sections/footer.tsx30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/components/sections/footer.tsx b/src/components/sections/footer.tsx
index 3a1b51d..a982810 100644
--- a/src/components/sections/footer.tsx
+++ b/src/components/sections/footer.tsx
@@ -1,18 +1,19 @@
import { baseOptions, linkItems, postsPerPage } from '@/app/(main)/layout.config';
import { InlineLink } from '@/components/inline-link';
-import { getSortedByDatePosts, getTags } from '@/lib/source';
+import { getPublishedPosts, getAllTags } from '@/lib/payload-posts';
import { cn } from '@/lib/utils';
import { getLinks } from 'fumadocs-ui/layouts/shared';
import { ActiveLink } from '../active-link';
-export function Footer() {
+export async function Footer() {
const links = getLinks(linkItems, baseOptions.githubUrl);
const navItems = links.filter((item) =>
['nav', 'all'].includes(item.on ?? 'all'),
);
- const posts = getSortedByDatePosts();
- const tags = getTags();
+ // 从 Payload 获取文章和标签
+ const { posts } = await getPublishedPosts({ limit: postsPerPage });
+ const tags = await getAllTags();
return (
<footer className={cn('flex flex-col gap-4')}>
@@ -54,7 +55,7 @@ export function Footer() {
{posts.slice(0, postsPerPage).map((post, i) => (
<li key={post.url}>
<ActiveLink key={i.toString()} href={post.url}>
- {post.data.title}
+ {post.title}
</ActiveLink>
</li>
))}
@@ -65,10 +66,10 @@ export function Footer() {
<p className='font-medium text-foreground'>Tags</p>
<ul className='flex flex-col gap-3'>
- {tags.slice(0, postsPerPage).map((name, i) => (
- <li key={`/tags/${name}`}>
- <ActiveLink key={i.toString()} href={`/tags/${name}`}>
- <span className='capitalize'>{name}</span>
+ {tags.slice(0, postsPerPage).map((item, i) => (
+ <li key={`/tags/${item.tag}`}>
+ <ActiveLink key={i.toString()} href={`/tags/${item.tag}`}>
+ <span className='capitalize'>{item.tag}</span>
</ActiveLink>
</li>
))}
@@ -96,17 +97,6 @@ export function Footer() {
</ul>
</div>
</div>
- {/* <Design /> */}
</footer>
);
}
-
-function Design() {
- return (
- <div className='footer'>
- <span className='footer-text font-mono'>john•doe</span>
- <div className='footer-grid' />
- <div className='footer-gradient' />
- </div>
- );
-}