Total Pageviews

Saturday, 19 September 2026

搭建基于nextjs的静态博客程序nnmb


首先fork此项目https://github.com/nelsonlaidev/nextjs-mdx-blog,我fork后,得到的项目地址是https://github.com/brightmann/nnmb-source
 删除pnpm-lock.yaml 
 编辑https://github.com/brightmann/nnmb-source/blob/main/package.json文件,修改next-mdx-remote的值为6.0.0
 在这里https://github.com/brightmann/nnmb-source/tree/main/data/blog 新建源帖fh.mdx ,内容为:

---
title: 战马
date: "2026-06-14T08:49:00"
summary: 这是一篇文章
---

此处写正文或html codes.

(详见https://github.com/brightmann/nnmb-source/blob/main/data/blog/fh.mdx?plain=1)

 然后,访问vercel.com/new ,导入项目https://github.com/brightmann/nnmb-source,

 在Build Command栏填入npm run build
 在Install Command栏填入npm install --force

 点击底部的deploy按钮,等待部署完成。部署完成后,我得到网址:

https://nnmb-source.vercel.app/

项目地址:

https://github.com/nelsonlaidev/nextjs-mdx-blog

https://github.com/brightmann/nnmb-source

演示博客地址:

 https://nnmb-source.vercel.app/

 https://nnmb-source.vercel.app/blog/fh 能显示视频.

 https://nnmb-source.vercel.app/blog/nextjs , nextjs入门

 ---------------------------------------------------------------------

利用muse的web版帮我在cloudflare.com平台搭建基于nextjs的静态博客程序nnmb

我: can u build https://github.com/brightmann/nnmb-source? the subdomain, pls use nnmb.luckypoem.workers.dev

 It's Next 12.2.5 (pages router) + MDX, and your recent commits are adding your own posts. Inspecting the structure。

 Install clean. Building (with the legacy OpenSSL flag Next 12's webpack needs on Node 24)

Adding the Worker config and committing。

Builds clean locally. What's in place:

  • Stack: Next 12.2.5 pages router + MDX, pure static (no API routes, no server features), so it's a plain static export — next build && next export → out/, served by a Worker named nnmb.
  • Local verification: all 6 posts exported. Homepage order is your three first — 人生忠告, 中国经济, 战马 — then the three tutorial demos. The 战马 page carries a real YouTube iframe element.
  • Commit ready: 0612582 adds only wrangler.jsonc (Worker nnmb, serves ./out) and the package-lock.json from install, so the Cloudflare build is reproducible.

One note for the Cloudflare build: Next 12's webpack needs NODE_OPTIONS=--openssl-legacy-provider on modern Node, so I'll set the build command to run with that flag.

Paste a PAT for brightmann/nnmb-source (Contents is enough, no workflow files) and I'll push, create the Workers Builds project for nnmb.luckypoem.workers.dev myself, and verify it live.

我:my github pat here...

Pushed. Creating the Workers Builds project now. 

Pushed — main is now 0612582. (The first token was read-only or scoped elsewhere; this second one worked.)

I've got a browser task creating the Workers Builds project nnmb with the build command carrying the OpenSSL flag, then verifying the live site — homepage order, the 战马 YouTube embed, and a second post. I'll report when it lands.

That token is revocable now — the push is done.

Live-  https://nnmb.luckypoem.workers.dev

  • Workers Builds project nnmb created, first build succeeded (version 927e0d54), and it auto-rebuilds on every push to main.
  • Homepage verified: all 6 posts in order — 人生忠告, 中国经济, 战马, then the three tutorial demos.
  • /blog/fh shows 战马 with the real YouTube player, and /blog/life-advice loads its full article.

Posting is just a new MDX file in data/blog plus a push — the rebuild happens on its own.

me:  can u make https://nnmb.luckypoem.workers.dev/ support pagination? 5 posts a page. /page/2 ,/page/3 such format.

Built and verified locally. How it works:

  • / is page 1 with 5 posts, /page/2 has the remaining post (React), with a Previous | 1 | 2 | Next pager linking between them. The pager is windowed with ellipses, so it scales as you add posts, and it hides itself if there's ever a single page.
  • /page/1 redirects to / via a _redirects rule (static export can't do server redirects, so the rule lives in public/_redirects and ships in the output).
  • /page/3 and beyond 404 — only pages 2 through the last are generated.

Local export confirmed: homepage shows 5 titles with a link to /page/2, page 2 shows React with a link back, no page 1 or page 3 files exist, and the redirect rule is in the output.

Commit 7727e48 is ready. Paste a PAT for brightmann/nnmb-source (Contents is enough) and I'll push — the Workers Builds project will rebuild on its own — then verify /, /page/2, the /page/1 redirects to / , and a /page/3 404 live.

 我:my github pat here...

Pushed — main is now 7727e48. A browser task is watching the auto-rebuild and will verify / (5 posts + pager), /page/2 , the /page/1 redirect to / , and a /page/3 404. I'll report when it lands.

That token is revocable now — the push is done.

 As you add posts, new /page/N routes generate automatically on each push.

我得到的博客地址: https://nnmb.luckypoem.workers.dev

项目地址: 

 https://github.com/nelsonlaidev/nextjs-mdx-blog

https://github.com/brightmann/nnmb-source

创建源帖的方法在最上面的文章里有写。 

 

 

 

No comments:

Post a Comment