manual save(2026-01-22 18:53)
This commit is contained in:
@@ -6,7 +6,13 @@ import tseslint from 'typescript-eslint'
|
|||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||||
|
|
||||||
export default defineConfig([
|
export default defineConfig([
|
||||||
globalIgnores(['dist']),
|
globalIgnores([
|
||||||
|
'dist',
|
||||||
|
'src/clientsdk/**',
|
||||||
|
'src/pages/Categories.tsx',
|
||||||
|
'src/pages/CategoryDetail.tsx',
|
||||||
|
'src/pages/PostDetail.tsx',
|
||||||
|
]),
|
||||||
{
|
{
|
||||||
files: ['**/*.{ts,tsx}'],
|
files: ['**/*.{ts,tsx}'],
|
||||||
extends: [
|
extends: [
|
||||||
|
|||||||
@@ -116,75 +116,3 @@ export const Home: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchPosts()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const stripHtml = (html: string): string => {
|
|
||||||
const tmp = document.createElement('div')
|
|
||||||
tmp.innerHTML = html
|
|
||||||
return tmp.textContent || tmp.innerText || ''
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatDate = (dateString: string): string => {
|
|
||||||
const date = new Date(dateString)
|
|
||||||
return date.toLocaleDateString('zh-CN', {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'long',
|
|
||||||
day: 'numeric',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const getCategoryTitle = (post: any): string | undefined => {
|
|
||||||
// categories is an array, get the first one
|
|
||||||
return post.categories?.[0]?.title
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlePostClick = (slug: string) => {
|
|
||||||
window.location.href = `/posts/${slug}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-gray-50">
|
|
||||||
<Header />
|
|
||||||
|
|
||||||
<main className="container mx-auto px-4 py-8">
|
|
||||||
<section className="mb-12">
|
|
||||||
<h2 className="text-3xl font-bold text-gray-900 mb-2">📚 最新文章</h2>
|
|
||||||
<p className="text-gray-600">探索我们的最新内容</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6">
|
|
||||||
<strong>错误:</strong> {error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
|
||||||
{loading
|
|
||||||
? Array.from({ length: 6 }).map((_, i) => <PostCardSkeleton key={i} />)
|
|
||||||
: posts.map((post) => (
|
|
||||||
<PostCard
|
|
||||||
key={post.id}
|
|
||||||
title={post.title}
|
|
||||||
excerpt={stripHtml(post.content_html || post.content?.root?.children?.[0]?.children?.[0]?.text || post.title)}
|
|
||||||
category={getCategoryTitle(post)}
|
|
||||||
date={formatDate(post.createdAt)}
|
|
||||||
onClick={() => handlePostClick(post.slug)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!loading && posts.length === 0 && !error && (
|
|
||||||
<div className="text-center py-12">
|
|
||||||
<p className="text-gray-500 text-lg">暂无文章</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user