Merge pull request #1048 from timlrx/next-15

Update to next-15
This commit is contained in:
Timothy 2024-11-03 12:02:54 +08:00 committed by GitHub
commit 5406b12662
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 2346 additions and 2420 deletions

View File

@ -1,6 +1,8 @@
import { NewsletterAPI } from 'pliny/newsletter' import { NewsletterAPI } from 'pliny/newsletter'
import siteMetadata from '@/data/siteMetadata' import siteMetadata from '@/data/siteMetadata'
export const dynamic = 'force-static'
const handler = NewsletterAPI({ const handler = NewsletterAPI({
// @ts-ignore // @ts-ignore
provider: siteMetadata.newsletter.provider, provider: siteMetadata.newsletter.provider,

View File

@ -21,11 +21,10 @@ const layouts = {
PostBanner, PostBanner,
} }
export async function generateMetadata({ export async function generateMetadata(props: {
params, params: Promise<{ slug: string[] }>
}: {
params: { slug: string[] }
}): Promise<Metadata | undefined> { }): Promise<Metadata | undefined> {
const params = await props.params
const slug = decodeURI(params.slug.join('/')) const slug = decodeURI(params.slug.join('/'))
const post = allBlogs.find((p) => p.slug === slug) const post = allBlogs.find((p) => p.slug === slug)
const authorList = post?.authors || ['default'] const authorList = post?.authors || ['default']
@ -78,7 +77,8 @@ export const generateStaticParams = async () => {
return allBlogs.map((p) => ({ slug: p.slug.split('/').map((name) => decodeURI(name)) })) return allBlogs.map((p) => ({ slug: p.slug.split('/').map((name) => decodeURI(name)) }))
} }
export default async function Page({ params }: { params: { slug: string[] } }) { export default async function Page(props: { params: Promise<{ slug: string[] }> }) {
const params = await props.params
const slug = decodeURI(params.slug.join('/')) const slug = decodeURI(params.slug.join('/'))
// Filter out drafts in production // Filter out drafts in production
const sortedCoreContents = allCoreContent(sortPosts(allBlogs)) const sortedCoreContents = allCoreContent(sortPosts(allBlogs))

View File

@ -11,7 +11,8 @@ export const generateStaticParams = async () => {
return paths return paths
} }
export default function Page({ params }: { params: { page: string } }) { export default async function Page(props: { params: Promise<{ page: string }> }) {
const params = await props.params
const posts = allCoreContent(sortPosts(allBlogs)) const posts = allCoreContent(sortPosts(allBlogs))
const pageNumber = parseInt(params.page as string) const pageNumber = parseInt(params.page as string)
const initialDisplayPosts = posts.slice( const initialDisplayPosts = posts.slice(

View File

@ -1,6 +1,8 @@
import { MetadataRoute } from 'next' import { MetadataRoute } from 'next'
import siteMetadata from '@/data/siteMetadata' import siteMetadata from '@/data/siteMetadata'
export const dynamic = 'force-static'
export default function robots(): MetadataRoute.Robots { export default function robots(): MetadataRoute.Robots {
return { return {
rules: { rules: {

View File

@ -2,6 +2,8 @@ import { MetadataRoute } from 'next'
import { allBlogs } from 'contentlayer/generated' import { allBlogs } from 'contentlayer/generated'
import siteMetadata from '@/data/siteMetadata' import siteMetadata from '@/data/siteMetadata'
export const dynamic = 'force-static'
export default function sitemap(): MetadataRoute.Sitemap { export default function sitemap(): MetadataRoute.Sitemap {
const siteUrl = siteMetadata.siteUrl const siteUrl = siteMetadata.siteUrl

View File

@ -8,7 +8,10 @@ import { genPageMetadata } from 'app/seo'
import { Metadata } from 'next' import { Metadata } from 'next'
import { notFound } from 'next/navigation' import { notFound } from 'next/navigation'
export async function generateMetadata({ params }: { params: { tag: string } }): Promise<Metadata> { export async function generateMetadata(props: {
params: Promise<{ tag: string }>
}): Promise<Metadata> {
const params = await props.params
const tag = decodeURI(params.tag) const tag = decodeURI(params.tag)
return genPageMetadata({ return genPageMetadata({
title: tag, title: tag,
@ -31,7 +34,8 @@ export const generateStaticParams = async () => {
return paths return paths
} }
export default function TagPage({ params }: { params: { tag: string } }) { export default async function TagPage(props: { params: Promise<{ tag: string }> }) {
const params = await props.params
const tag = decodeURI(params.tag) const tag = decodeURI(params.tag)
// Capitalize first letter and convert space to dash // Capitalize first letter and convert space to dash
const title = tag[0].toUpperCase() + tag.split(' ').join('-').slice(1) const title = tag[0].toUpperCase() + tag.split(' ').join('-').slice(1)

View File

@ -12,25 +12,25 @@
"prepare": "husky" "prepare": "husky"
}, },
"dependencies": { "dependencies": {
"@headlessui/react": "1.7.19", "@headlessui/react": "2.2.0",
"@next/bundle-analyzer": "14.2.3", "@next/bundle-analyzer": "15.0.2",
"@tailwindcss/forms": "^0.5.7", "@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.12", "@tailwindcss/typography": "^0.5.15",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"body-scroll-lock": "^4.0.0-beta.0", "body-scroll-lock": "^4.0.0-beta.0",
"contentlayer2": "0.5.1", "contentlayer2": "0.5.3",
"esbuild": "0.20.2", "esbuild": "0.20.2",
"github-slugger": "^2.0.0", "github-slugger": "^2.0.0",
"gray-matter": "^4.0.2", "gray-matter": "^4.0.2",
"hast-util-from-html-isomorphic": "^2.0.0", "hast-util-from-html-isomorphic": "^2.0.0",
"image-size": "1.0.0", "image-size": "1.0.0",
"next": "14.2.3", "next": "15.0.2",
"next-contentlayer2": "0.5.1", "next-contentlayer2": "0.5.3",
"next-themes": "^0.3.0", "next-themes": "^0.3.0",
"pliny": "0.2.1", "pliny": "0.4.0",
"postcss": "^8.4.24", "postcss": "^8.4.24",
"react": "18.3.1", "react": "rc",
"react-dom": "18.3.1", "react-dom": "rc",
"reading-time": "1.5.0", "reading-time": "1.5.0",
"rehype-autolink-headings": "^7.1.0", "rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.0.0", "rehype-citation": "^2.0.0",
@ -42,20 +42,20 @@
"remark-gfm": "^4.0.0", "remark-gfm": "^4.0.0",
"remark-github-blockquote-alert": "^1.2.1", "remark-github-blockquote-alert": "^1.2.1",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"tailwindcss": "^3.4.3", "tailwindcss": "^3.4.14",
"unist-util-visit": "^5.0.0" "unist-util-visit": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@svgr/webpack": "^8.0.1", "@svgr/webpack": "^8.0.1",
"@types/mdx": "^2.0.12", "@types/mdx": "^2.0.12",
"@types/react": "^18.2.73", "@types/react": "^18.2.73",
"@typescript-eslint/eslint-plugin": "^6.1.0", "@typescript-eslint/eslint-plugin": "^8.12.0",
"@typescript-eslint/parser": "^6.1.0", "@typescript-eslint/parser": "^8.12.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^8.45.0", "eslint": "^9.14.0",
"eslint-config-next": "14.2.3", "eslint-config-next": "15.0.2",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.2.0",
"husky": "^9.0.0", "husky": "^9.0.0",
"lint-staged": "^13.0.0", "lint-staged": "^13.0.0",
"prettier": "^3.0.0", "prettier": "^3.0.0",

View File

@ -47,9 +47,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
if (publishPosts.length > 0) { if (publishPosts.length > 0) {
for (const tag of Object.keys(tagData)) { for (const tag of Object.keys(tagData)) {
const filteredPosts = allBlogs.filter((post) => const filteredPosts = allBlogs.filter((post) => post.tags.map((t) => slug(t)).includes(tag))
post.tags.map((t) => slug(t)).includes(tag)
)
const rss = generateRss(config, filteredPosts, `tags/${tag}/${page}`) const rss = generateRss(config, filteredPosts, `tags/${tag}/${page}`)
const rssPath = path.join(outputFolder, 'tags', tag) const rssPath = path.join(outputFolder, 'tags', tag)
mkdirSync(rssPath, { recursive: true }) mkdirSync(rssPath, { recursive: true })

4701
yarn.lock

File diff suppressed because it is too large Load Diff