Ensure contentlayer build artifacts and fix blog rendering

This commit is contained in:
cloudneutral 2025-12-22 12:56:21 +08:00
parent e54ab3eb01
commit c4ea113657
4 changed files with 12 additions and 12 deletions

View File

@ -7,7 +7,7 @@
}, },
"scripts": { "scripts": {
"dev": "next dev --turbo", "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": "next build",
"build:static": "npm run prebuild && next build", "build:static": "npm run prebuild && next build",
"start": "node ./scripts/start.js", "start": "node ./scripts/start.js",
@ -39,6 +39,7 @@
"@tiptap/starter-kit": "^3.13.0", "@tiptap/starter-kit": "^3.13.0",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"contentlayer": "^0.3.4",
"dompurify": "^3.2.6", "dompurify": "^3.2.6",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
@ -49,6 +50,7 @@
"marked": "^16.1.2", "marked": "^16.1.2",
"mermaid": "^11.12.2", "mermaid": "^11.12.2",
"next": "^16.0.9", "next": "^16.0.9",
"next-contentlayer": "^0.3.4",
"next-mdx-remote": "^5.0.0", "next-mdx-remote": "^5.0.0",
"next-themes": "^0.4.6", "next-themes": "^0.4.6",
"pdfjs-dist": "^4.2.67", "pdfjs-dist": "^4.2.67",
@ -82,11 +84,9 @@
"@types/sanitize-html": "^2.16.0", "@types/sanitize-html": "^2.16.0",
"autoprefixer": "^10.4.16", "autoprefixer": "^10.4.16",
"baseline-browser-mapping": "^2.8.32", "baseline-browser-mapping": "^2.8.32",
"contentlayer": "^0.3.4",
"eslint": "8.57.0", "eslint": "8.57.0",
"eslint-config-next": "^15.5.3", "eslint-config-next": "^15.5.3",
"jsdom": "^24.0.0", "jsdom": "^24.0.0",
"next-contentlayer": "^0.3.4",
"postcss": "^8.4.32", "postcss": "^8.4.32",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"tailwindcss": "^3.4.3", "tailwindcss": "^3.4.3",

View File

@ -1,12 +1,11 @@
export const dynamic = 'error' export const dynamic = 'force-dynamic'
export const revalidate = false
import Link from 'next/link' import Link from 'next/link'
import { notFound } from 'next/navigation' import { notFound } from 'next/navigation'
import { compileMDX } from 'next-mdx-remote/rsc' import { compileMDX } from 'next-mdx-remote/rsc'
import type { Metadata } from 'next' import type { Metadata } from 'next'
import { getBlogPostBySlug, getBlogSlugs } from '@lib/blogContent' import { getBlogPostBySlug } from '@lib/blogContent'
type PageProps = { type PageProps = {
params: { slug: string | string[] } 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> { export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
const slugParam = await params const slugParam = await params
const slugPath = Array.isArray(slugParam.slug) ? slugParam.slug.join('/') : slugParam.slug const slugPath = Array.isArray(slugParam.slug) ? slugParam.slug.join('/') : slugParam.slug

View File

@ -2,6 +2,7 @@ export const dynamic = 'error'
export const revalidate = false export const revalidate = false
import type { Metadata } from 'next' import type { Metadata } from 'next'
import { Suspense } from 'react'
import BlogList from '@components/blog/BlogList' import BlogList from '@components/blog/BlogList'
import { getBlogPosts } from '@lib/blogContent' import { getBlogPosts } from '@lib/blogContent'
@ -13,5 +14,9 @@ export const metadata: Metadata = {
export default async function BlogPage() { export default async function BlogPage() {
const posts = await getBlogPosts() 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>
)
} }

View File

@ -17,6 +17,7 @@
"jsx": "react-jsx", "jsx": "react-jsx",
"baseUrl": ".", // 👈 "baseUrl": ".", // 👈
"paths": { "paths": {
"contentlayer/generated": ["./.contentlayer/generated"],
"@/*": ["src/*"], "@/*": ["src/*"],
"@components/*": ["src/components/*"], "@components/*": ["src/components/*"],
"@i18n/*": ["src/i18n/*"], "@i18n/*": ["src/i18n/*"],