feat(site): 预渲染 503 静态课程页修复 SEO 空壳#28
Merged
Merged
Conversation
- 新增 writeLessonPages:构建时用与浏览器同一份渲染器把正文烤进 site/lessons/<phase>/<lesson>/index.html,每课独立 title/desc/canonical/JSON-LD - parseMd 等纯函数簇从 lesson.html 抽至 md-render.js(浏览器与 Node 共用, 预渲染产物 = 运行时渲染产物) - lesson.html boot 识别 __PRERENDERED__:跳过 fetch,setTimeout(0) 后直接 enhanceLesson + fetchQuiz(同步调用会踩 var 赋值未执行的坑) - 站内全部 lesson 链接(sidebar/上下课/时间线/cmdpalette/app/prereqs)和 sitemap/llms.txt 切到 /lessons/ 静态 URL;旧 ?path= 入口保留,canonical 指静态页 - 产物 gitignore(同 sitemap/llms 策略,Vercel buildCommand 生成);vercel.json 补 /lessons/ 缓存头
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- writeLessonPages 三个模板锚点(LOADING_BLOCK / md-render script / </head>)前置校验,任一失配即中止构建;__PRERENDERED__ 注入后逐页断言 (注入丢失的后果是 boot showError 把烤好的正文覆盖成错误页,必须拦死) - 烤进静态页的 prev/next 导航只指向 zh.md 真实存在的课,避免 /lessons/ 404 - figure 块 data-figure 属性改用 escapeAttr(含双引号会截断属性, lesson.html 旧实现同款潜在 bug,共享渲染器一并修正) - updateLessonSeo 空 path 防御(避免生成 /lessons// 坏 canonical)
Owner
Author
|
双审(Codex + 独立 subagent)已完成,结论:无严重 bug,5 个有效发现已全部落实在 cca900b:
不修(有意决策):
修复后已重新本地验证:build 503/503、--check 通过、浏览器实测正文/quiz/mermaid/figure/控制台零错误。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
503 个课程页此前是
lesson.html?path=单页 + 运行时 fetch 渲染,爬虫拿到的是字节级相同的空壳(实测两课 md5 一致):百度不执行跨域 fetch,Google 对新站渲染预算极少。sitemap 交了 508 个 URL,实际收录约等于只有首页。方案
site/md-render.js(新增):parseMd / inlineFormat / renderCodeBlock 等纯函数簇从 lesson.html 原样抽出,UMD 导出,浏览器与 Node 共用同一份渲染器 → 预渲染产物 = 运行时渲染产物,不存在两套渲染器漂移。build.js新增writeLessonPages:构建时把正文烤进site/lessons/<phase>/<lesson>/index.html,每课独立 title / description / canonical / og:url / JSON-LD,lang=zh-CN;模板相对路径绝对化;上下课导航与客户端 addBottomNav 同构。产物 gitignore(同 sitemap/llms 策略,Vercel buildCommand 生成),503 页共 67MB。__PRERENDERED__标记 → 跳过 fetch,setTimeout(0)后 enhanceLesson + fetchQuiz(同步调用会踩 IIFE 底部 var 赋值未执行的坑,已实测踩中并修复)。renderLesson 拆出 enhanceLesson 供两条路径共用。/lessons/静态 URL;sitemap、llms.txt 同步。旧?path=入口保留兼容,canonical 指向静态页。/lessons/(.*)缓存头。已验证(本地 http.server + Chrome 实测)
--check课数护栏通过?path=入口照常工作,与预渲染页渲染结果一致没验证到