Merge pull request #17 from Cloud-Neutral-Toolkit/codex/fix-build-error-with-contentlayer
Fix contentlayer generation and stabilize blog build
This commit is contained in:
commit
22c6ee0f30
@ -7,7 +7,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev --turbo",
|
||||
"prebuild": "tsx ../scripts/export-slugs.ts && tsx ../scripts/scan-md.ts && tsx ../scripts/fetch-dl-index.ts && node ../scripts/copy-manifests.js",
|
||||
"prebuild": "tsx ../scripts/export-slugs.ts && tsx ../scripts/scan-md.ts && tsx ../scripts/fetch-dl-index.ts && node ../scripts/copy-manifests.js && contentlayer build",
|
||||
"build": "next build",
|
||||
"build:static": "npm run prebuild && next build",
|
||||
"start": "node ./scripts/start.js",
|
||||
@ -39,6 +39,7 @@
|
||||
"@tiptap/starter-kit": "^3.13.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"contentlayer": "^0.3.4",
|
||||
"dompurify": "^3.2.6",
|
||||
"gray-matter": "^4.0.3",
|
||||
"html2canvas": "^1.4.1",
|
||||
@ -49,6 +50,7 @@
|
||||
"marked": "^16.1.2",
|
||||
"mermaid": "^11.12.2",
|
||||
"next": "^16.0.9",
|
||||
"next-contentlayer": "^0.3.4",
|
||||
"next-mdx-remote": "^5.0.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"pdfjs-dist": "^4.2.67",
|
||||
@ -82,11 +84,9 @@
|
||||
"@types/sanitize-html": "^2.16.0",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"baseline-browser-mapping": "^2.8.32",
|
||||
"contentlayer": "^0.3.4",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-config-next": "^15.5.3",
|
||||
"jsdom": "^24.0.0",
|
||||
"next-contentlayer": "^0.3.4",
|
||||
"postcss": "^8.4.32",
|
||||
"prettier": "^3.3.3",
|
||||
"tailwindcss": "^3.4.3",
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
export const dynamic = 'error'
|
||||
export const revalidate = false
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
import Link from 'next/link'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { compileMDX } from 'next-mdx-remote/rsc'
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
import { getBlogPostBySlug, getBlogSlugs } from '@lib/blogContent'
|
||||
import { getBlogPostBySlug } from '@lib/blogContent'
|
||||
|
||||
type PageProps = {
|
||||
params: { slug: string | string[] }
|
||||
@ -30,11 +29,6 @@ function formatDate(dateStr: string, language: 'zh' | 'en'): string {
|
||||
})
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const slugs = await getBlogSlugs()
|
||||
return slugs.map((slug) => ({ slug: slug.split('/') }))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const slugParam = await params
|
||||
const slugPath = Array.isArray(slugParam.slug) ? slugParam.slug.join('/') : slugParam.slug
|
||||
|
||||
@ -2,6 +2,7 @@ export const dynamic = 'error'
|
||||
export const revalidate = false
|
||||
|
||||
import type { Metadata } from 'next'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
import BlogList from '@components/blog/BlogList'
|
||||
import { getBlogPosts } from '@lib/blogContent'
|
||||
@ -13,5 +14,9 @@ export const metadata: Metadata = {
|
||||
|
||||
export default async function BlogPage() {
|
||||
const posts = await getBlogPosts()
|
||||
return <BlogList posts={posts} />
|
||||
return (
|
||||
<Suspense fallback={<div className="p-6 text-center">Loading blog content...</div>}>
|
||||
<BlogList posts={posts} />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": ".", // 👈 根路径基准
|
||||
"paths": {
|
||||
"contentlayer/generated": ["./.contentlayer/generated"],
|
||||
"@/*": ["src/*"],
|
||||
"@components/*": ["src/components/*"],
|
||||
"@i18n/*": ["src/i18n/*"],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user