[{"data":1,"prerenderedAt":1389},["ShallowReactive",2],{"note:/notes/nuxt-content-static-notes":3,"notes-summary":1318},[4],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"updated":11,"category":12,"body":13,"_type":1311,"_id":1312,"_source":1313,"_file":1314,"_stem":1315,"_extension":1316,"sitemap":1317},"/notes/nuxt-content-static-notes","notes",false,"","用 Nuxt Content 给翼程官网做一个静态 Markdown 栏目","拆解翼程笔记的实际实现，说明 Nuxt Content 查询与渲染、动态路由预渲染、站点地图日期同步，以及排查草稿进入静态缓存的过程。","2026-11-19","开发心得",{"type":14,"children":15,"toc":1305},"root",[16,33,40,79,140,169,175,226,231,1007,1012,1057,1122,1151,1184,1189,1257,1299],{"type":17,"tag":18,"props":19,"children":20},"element","p",{},[21,24,31],{"type":22,"value":23},"text","「翼程笔记」第一版刚做好时，页面上一切正常：文章能打开，列表里也看不到下划线开头的写作模板。但我们去翻构建出来的 ",{"type":17,"tag":25,"props":26,"children":28},"code",{"className":27},[],[29],{"type":22,"value":30},".output/public/api/_content/cache.*.json",{"type":22,"value":32}," 时，却在静态缓存里搜到了模板文件的标题和正文。顺着这个问题，我们把 Nuxt Content 读源文件、Nitro 预渲染路由和发布前检查生成文件的整条链路重新梳理了一遍。",{"type":17,"tag":34,"props":35,"children":37},"h2",{"id":36},"沿用已有的-nuxt-content保留官网自己的详情页",[38],{"type":22,"value":39},"沿用已有的 Nuxt Content，保留官网自己的详情页",{"type":17,"tag":18,"props":41,"children":42},{},[43,45,51,53,59,61,70,72],{"type":22,"value":44},"翼程官网本来就是 Nuxt 3 项目，依赖里已经装了 ",{"type":17,"tag":25,"props":46,"children":48},{"className":47},[],[49],{"type":22,"value":50},"@nuxt/content",{"type":22,"value":52}," 2.x。早先做的「开发指南」栏目结构很固定，当时自己写了个解析器来拆清单、表格和常见问题；但「翼程笔记」要写日常代码和踩坑记录，正文里到处是行内代码、代码块、外链和多级小标题，直接交给 Nuxt Content 解析要省心得多。代码高亮用它自带的 Shiki，文章开头依然用 YAML 填写标题、摘要和 ",{"type":17,"tag":25,"props":54,"children":56},{"className":55},[],[57],{"type":22,"value":58},"updated",{"type":22,"value":60},"。 ",{"type":17,"tag":62,"props":63,"children":67},"a",{"href":64,"rel":65},"https://v2.content.nuxt.com/usage/render/",[66],"nofollow",[68],{"type":22,"value":69},"Nuxt Content v2 渲染文档",{"type":22,"value":71}," · ",{"type":17,"tag":62,"props":73,"children":76},{"href":74,"rel":75},"https://v2.content.nuxt.com/get-started/configuration/#highlight",[66],[77],{"type":22,"value":78},"代码高亮配置",{"type":17,"tag":18,"props":80,"children":81},{},[82,84,90,92,98,100,106,108,114,116,122,124,130,132,138],{"type":22,"value":83},"列表页调用 ",{"type":17,"tag":25,"props":85,"children":87},{"className":86},[],[88],{"type":22,"value":89},"queryContent()",{"type":22,"value":91}," 读取 ",{"type":17,"tag":25,"props":93,"children":95},{"className":94},[],[96],{"type":22,"value":97},"content/notes/",{"type":22,"value":99}," 下的公开 Markdown，再用 ",{"type":17,"tag":25,"props":101,"children":103},{"className":102},[],[104],{"type":22,"value":105},".only()",{"type":22,"value":107}," 只取路径、标题、摘要、日期和分类五个字段，免得把整篇正文都塞进列表页的 payload 里。详情页由 ",{"type":17,"tag":25,"props":109,"children":111},{"className":110},[],[112],{"type":22,"value":113},"pages/notes/[slug].vue",{"type":22,"value":115}," 按 ",{"type":17,"tag":25,"props":117,"children":119},{"className":118},[],[120],{"type":22,"value":121},"_path",{"type":22,"value":123}," 查出单篇文章，正文交给 ",{"type":17,"tag":25,"props":125,"children":127},{"className":126},[],[128],{"type":22,"value":129},"\u003CContentRenderer>",{"type":22,"value":131}," 渲染，页头、面包屑和 SEO 结构化数据则继续用官网原本那套组件和 ",{"type":17,"tag":25,"props":133,"children":135},{"className":134},[],[136],{"type":22,"value":137},"usePageSeo()",{"type":22,"value":139},"。",{"type":17,"tag":18,"props":141,"children":142},{},[143,145,151,153,159,161,167],{"type":22,"value":144},"因为所有笔记共用同一个详情页组件，我们在页面配置里把 key 设成了 ",{"type":17,"tag":25,"props":146,"children":148},{"className":147},[],[149],{"type":22,"value":150},"route.path",{"type":22,"value":152},"，",{"type":17,"tag":25,"props":154,"children":156},{"className":155},[],[157],{"type":22,"value":158},"useAsyncData()",{"type":22,"value":160}," 的 key 也拼上了文章路径（比如 ",{"type":17,"tag":25,"props":162,"children":164},{"className":163},[],[165],{"type":22,"value":166},"note:/notes/nuxt-content-static-notes",{"type":22,"value":168},"）。这样访客在站内从一篇跳到另一篇时，组件会干脆地按新路径重新取数和更新页面标题，不会残留上一篇的状态。",{"type":17,"tag":34,"props":170,"children":172},{"id":171},"从-markdown-文件明确登记预渲染路由",[173],{"type":22,"value":174},"从 Markdown 文件明确登记预渲染路由",{"type":17,"tag":18,"props":176,"children":177},{},[178,180,186,188,194,196,202,204,210,212,217,219],{"type":22,"value":179},"本地跑 ",{"type":17,"tag":25,"props":181,"children":183},{"className":182},[],[184],{"type":22,"value":185},"nuxt dev",{"type":22,"value":187}," 时，访问 ",{"type":17,"tag":25,"props":189,"children":191},{"className":190},[],[192],{"type":22,"value":193},"/notes/hello",{"type":22,"value":195}," 是现场去读 Markdown 文件；但官网线上是纯静态托管，构建时必须把每篇笔记的 HTML 提前生成好。虽然 Nitro 预渲染能顺着列表页上的 ",{"type":17,"tag":25,"props":197,"children":199},{"className":198},[],[200],{"type":22,"value":201},"\u003Ca>",{"type":22,"value":203}," 链接往下爬，我们还是在 ",{"type":17,"tag":25,"props":205,"children":207},{"className":206},[],[208],{"type":22,"value":209},"nuxt.config.ts",{"type":22,"value":211}," 里直接扫了一遍 ",{"type":17,"tag":25,"props":213,"children":215},{"className":214},[],[216],{"type":22,"value":97},{"type":22,"value":218}," 目录，把正式笔记的路径一个个塞进预渲染列表。这样就算哪天列表页的查询条件写错了、漏了某篇，构建时照样会去生成详情页，后面的发布检查也能立刻揪出列表和文件对不上的问题。 ",{"type":17,"tag":62,"props":220,"children":223},{"href":221,"rel":222},"https://nuxt.com/docs/3.x/getting-started/prerendering",[66],[224],{"type":22,"value":225},"Nuxt 3 预渲染文档",{"type":17,"tag":18,"props":227,"children":228},{},[229],{"type":22,"value":230},"构建配置里和笔记相关的部分大体是这样（省掉了其他栏目的设置）：",{"type":17,"tag":232,"props":233,"children":237},"pre",{"className":234,"code":235,"language":236,"meta":8,"style":8},"language-ts shiki shiki-themes github-dark","import { readdirSync } from 'node:fs'\n\n// 读取笔记目录的直接子文件，下划线开头的模板和草稿不登记路由。\nconst files = readdirSync(new URL('./content/notes/', import.meta.url), { withFileTypes: true })\nconst noteRoutes = files\n  .filter(file => file.isFile() && file.name.endsWith('.md') && !file.name.startsWith('_'))\n  .map(file => {\n    const slug = file.name.slice(0, -3)\n    // 保留稳定的英文路径，并把 index 留给栏目首页。\n    if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) || slug === 'index') {\n      throw new Error(`笔记文件名不符合约定：${file.name}`)\n    }\n    return `/notes/${slug}`\n  })\n\nexport default defineNuxtConfig({\n  nitro: {\n    prerender: {\n      crawlLinks: true,\n      // 详情缺失或渲染失败时终止构建，由发布流程保留上一次产物。\n      failOnError: true,\n      routes: ['/notes', ...noteRoutes]\n    }\n  },\n  content: {\n    // 在内容模块读入文件时排除笔记草稿，避免进入公开的静态缓存。\n    ignores: ['/notes/_'],\n    highlight: { theme: 'github-dark' }\n  }\n})\n","ts",[238],{"type":17,"tag":25,"props":239,"children":240},{"__ignoreMap":8},[241,270,280,290,374,396,502,532,587,596,702,752,761,785,794,802,826,835,844,862,871,888,916,924,933,942,951,970,989,998],{"type":17,"tag":242,"props":243,"children":246},"span",{"class":244,"line":245},"line",1,[247,253,259,264],{"type":17,"tag":242,"props":248,"children":250},{"style":249},"--shiki-default:#F97583",[251],{"type":22,"value":252},"import",{"type":17,"tag":242,"props":254,"children":256},{"style":255},"--shiki-default:#E1E4E8",[257],{"type":22,"value":258}," { readdirSync } ",{"type":17,"tag":242,"props":260,"children":261},{"style":249},[262],{"type":22,"value":263},"from",{"type":17,"tag":242,"props":265,"children":267},{"style":266},"--shiki-default:#9ECBFF",[268],{"type":22,"value":269}," 'node:fs'\n",{"type":17,"tag":242,"props":271,"children":273},{"class":244,"line":272},2,[274],{"type":17,"tag":242,"props":275,"children":277},{"emptyLinePlaceholder":276},true,[278],{"type":22,"value":279},"\n",{"type":17,"tag":242,"props":281,"children":283},{"class":244,"line":282},3,[284],{"type":17,"tag":242,"props":285,"children":287},{"style":286},"--shiki-default:#6A737D",[288],{"type":22,"value":289},"// 读取笔记目录的直接子文件，下划线开头的模板和草稿不登记路由。\n",{"type":17,"tag":242,"props":291,"children":293},{"class":244,"line":292},4,[294,299,305,310,316,321,326,331,335,340,345,349,354,359,364,369],{"type":17,"tag":242,"props":295,"children":296},{"style":249},[297],{"type":22,"value":298},"const",{"type":17,"tag":242,"props":300,"children":302},{"style":301},"--shiki-default:#79B8FF",[303],{"type":22,"value":304}," files",{"type":17,"tag":242,"props":306,"children":307},{"style":249},[308],{"type":22,"value":309}," =",{"type":17,"tag":242,"props":311,"children":313},{"style":312},"--shiki-default:#B392F0",[314],{"type":22,"value":315}," readdirSync",{"type":17,"tag":242,"props":317,"children":318},{"style":255},[319],{"type":22,"value":320},"(",{"type":17,"tag":242,"props":322,"children":323},{"style":249},[324],{"type":22,"value":325},"new",{"type":17,"tag":242,"props":327,"children":328},{"style":312},[329],{"type":22,"value":330}," URL",{"type":17,"tag":242,"props":332,"children":333},{"style":255},[334],{"type":22,"value":320},{"type":17,"tag":242,"props":336,"children":337},{"style":266},[338],{"type":22,"value":339},"'./content/notes/'",{"type":17,"tag":242,"props":341,"children":342},{"style":255},[343],{"type":22,"value":344},", ",{"type":17,"tag":242,"props":346,"children":347},{"style":249},[348],{"type":22,"value":252},{"type":17,"tag":242,"props":350,"children":351},{"style":255},[352],{"type":22,"value":353},".",{"type":17,"tag":242,"props":355,"children":356},{"style":301},[357],{"type":22,"value":358},"meta",{"type":17,"tag":242,"props":360,"children":361},{"style":255},[362],{"type":22,"value":363},".url), { withFileTypes: ",{"type":17,"tag":242,"props":365,"children":366},{"style":301},[367],{"type":22,"value":368},"true",{"type":17,"tag":242,"props":370,"children":371},{"style":255},[372],{"type":22,"value":373}," })\n",{"type":17,"tag":242,"props":375,"children":377},{"class":244,"line":376},5,[378,382,387,391],{"type":17,"tag":242,"props":379,"children":380},{"style":249},[381],{"type":22,"value":298},{"type":17,"tag":242,"props":383,"children":384},{"style":301},[385],{"type":22,"value":386}," noteRoutes",{"type":17,"tag":242,"props":388,"children":389},{"style":249},[390],{"type":22,"value":309},{"type":17,"tag":242,"props":392,"children":393},{"style":255},[394],{"type":22,"value":395}," files\n",{"type":17,"tag":242,"props":397,"children":399},{"class":244,"line":398},6,[400,405,410,414,420,425,430,435,440,445,450,455,459,464,469,473,478,483,488,492,497],{"type":17,"tag":242,"props":401,"children":402},{"style":255},[403],{"type":22,"value":404},"  .",{"type":17,"tag":242,"props":406,"children":407},{"style":312},[408],{"type":22,"value":409},"filter",{"type":17,"tag":242,"props":411,"children":412},{"style":255},[413],{"type":22,"value":320},{"type":17,"tag":242,"props":415,"children":417},{"style":416},"--shiki-default:#FFAB70",[418],{"type":22,"value":419},"file",{"type":17,"tag":242,"props":421,"children":422},{"style":249},[423],{"type":22,"value":424}," =>",{"type":17,"tag":242,"props":426,"children":427},{"style":255},[428],{"type":22,"value":429}," file.",{"type":17,"tag":242,"props":431,"children":432},{"style":312},[433],{"type":22,"value":434},"isFile",{"type":17,"tag":242,"props":436,"children":437},{"style":255},[438],{"type":22,"value":439},"() ",{"type":17,"tag":242,"props":441,"children":442},{"style":249},[443],{"type":22,"value":444},"&&",{"type":17,"tag":242,"props":446,"children":447},{"style":255},[448],{"type":22,"value":449}," file.name.",{"type":17,"tag":242,"props":451,"children":452},{"style":312},[453],{"type":22,"value":454},"endsWith",{"type":17,"tag":242,"props":456,"children":457},{"style":255},[458],{"type":22,"value":320},{"type":17,"tag":242,"props":460,"children":461},{"style":266},[462],{"type":22,"value":463},"'.md'",{"type":17,"tag":242,"props":465,"children":466},{"style":255},[467],{"type":22,"value":468},") ",{"type":17,"tag":242,"props":470,"children":471},{"style":249},[472],{"type":22,"value":444},{"type":17,"tag":242,"props":474,"children":475},{"style":249},[476],{"type":22,"value":477}," !",{"type":17,"tag":242,"props":479,"children":480},{"style":255},[481],{"type":22,"value":482},"file.name.",{"type":17,"tag":242,"props":484,"children":485},{"style":312},[486],{"type":22,"value":487},"startsWith",{"type":17,"tag":242,"props":489,"children":490},{"style":255},[491],{"type":22,"value":320},{"type":17,"tag":242,"props":493,"children":494},{"style":266},[495],{"type":22,"value":496},"'_'",{"type":17,"tag":242,"props":498,"children":499},{"style":255},[500],{"type":22,"value":501},"))\n",{"type":17,"tag":242,"props":503,"children":505},{"class":244,"line":504},7,[506,510,515,519,523,527],{"type":17,"tag":242,"props":507,"children":508},{"style":255},[509],{"type":22,"value":404},{"type":17,"tag":242,"props":511,"children":512},{"style":312},[513],{"type":22,"value":514},"map",{"type":17,"tag":242,"props":516,"children":517},{"style":255},[518],{"type":22,"value":320},{"type":17,"tag":242,"props":520,"children":521},{"style":416},[522],{"type":22,"value":419},{"type":17,"tag":242,"props":524,"children":525},{"style":249},[526],{"type":22,"value":424},{"type":17,"tag":242,"props":528,"children":529},{"style":255},[530],{"type":22,"value":531}," {\n",{"type":17,"tag":242,"props":533,"children":535},{"class":244,"line":534},8,[536,541,546,550,554,559,563,568,572,577,582],{"type":17,"tag":242,"props":537,"children":538},{"style":249},[539],{"type":22,"value":540},"    const",{"type":17,"tag":242,"props":542,"children":543},{"style":301},[544],{"type":22,"value":545}," slug",{"type":17,"tag":242,"props":547,"children":548},{"style":249},[549],{"type":22,"value":309},{"type":17,"tag":242,"props":551,"children":552},{"style":255},[553],{"type":22,"value":449},{"type":17,"tag":242,"props":555,"children":556},{"style":312},[557],{"type":22,"value":558},"slice",{"type":17,"tag":242,"props":560,"children":561},{"style":255},[562],{"type":22,"value":320},{"type":17,"tag":242,"props":564,"children":565},{"style":301},[566],{"type":22,"value":567},"0",{"type":17,"tag":242,"props":569,"children":570},{"style":255},[571],{"type":22,"value":344},{"type":17,"tag":242,"props":573,"children":574},{"style":249},[575],{"type":22,"value":576},"-",{"type":17,"tag":242,"props":578,"children":579},{"style":301},[580],{"type":22,"value":581},"3",{"type":17,"tag":242,"props":583,"children":584},{"style":255},[585],{"type":22,"value":586},")\n",{"type":17,"tag":242,"props":588,"children":590},{"class":244,"line":589},9,[591],{"type":17,"tag":242,"props":592,"children":593},{"style":286},[594],{"type":22,"value":595},"    // 保留稳定的英文路径，并把 index 留给栏目首页。\n",{"type":17,"tag":242,"props":597,"children":599},{"class":244,"line":598},10,[600,605,610,615,620,625,630,635,641,645,649,654,659,663,667,672,677,682,687,692,697],{"type":17,"tag":242,"props":601,"children":602},{"style":249},[603],{"type":22,"value":604},"    if",{"type":17,"tag":242,"props":606,"children":607},{"style":255},[608],{"type":22,"value":609}," (",{"type":17,"tag":242,"props":611,"children":612},{"style":249},[613],{"type":22,"value":614},"!",{"type":17,"tag":242,"props":616,"children":617},{"style":266},[618],{"type":22,"value":619},"/",{"type":17,"tag":242,"props":621,"children":622},{"style":249},[623],{"type":22,"value":624},"^",{"type":17,"tag":242,"props":626,"children":627},{"style":301},[628],{"type":22,"value":629},"[a-z0-9]",{"type":17,"tag":242,"props":631,"children":632},{"style":249},[633],{"type":22,"value":634},"+",{"type":17,"tag":242,"props":636,"children":638},{"style":637},"--shiki-default:#DBEDFF",[639],{"type":22,"value":640},"(?:-",{"type":17,"tag":242,"props":642,"children":643},{"style":301},[644],{"type":22,"value":629},{"type":17,"tag":242,"props":646,"children":647},{"style":249},[648],{"type":22,"value":634},{"type":17,"tag":242,"props":650,"children":651},{"style":637},[652],{"type":22,"value":653},")",{"type":17,"tag":242,"props":655,"children":656},{"style":249},[657],{"type":22,"value":658},"*$",{"type":17,"tag":242,"props":660,"children":661},{"style":266},[662],{"type":22,"value":619},{"type":17,"tag":242,"props":664,"children":665},{"style":255},[666],{"type":22,"value":353},{"type":17,"tag":242,"props":668,"children":669},{"style":312},[670],{"type":22,"value":671},"test",{"type":17,"tag":242,"props":673,"children":674},{"style":255},[675],{"type":22,"value":676},"(slug) ",{"type":17,"tag":242,"props":678,"children":679},{"style":249},[680],{"type":22,"value":681},"||",{"type":17,"tag":242,"props":683,"children":684},{"style":255},[685],{"type":22,"value":686}," slug ",{"type":17,"tag":242,"props":688,"children":689},{"style":249},[690],{"type":22,"value":691},"===",{"type":17,"tag":242,"props":693,"children":694},{"style":266},[695],{"type":22,"value":696}," 'index'",{"type":17,"tag":242,"props":698,"children":699},{"style":255},[700],{"type":22,"value":701},") {\n",{"type":17,"tag":242,"props":703,"children":705},{"class":244,"line":704},11,[706,711,716,721,725,730,734,738,743,748],{"type":17,"tag":242,"props":707,"children":708},{"style":249},[709],{"type":22,"value":710},"      throw",{"type":17,"tag":242,"props":712,"children":713},{"style":249},[714],{"type":22,"value":715}," new",{"type":17,"tag":242,"props":717,"children":718},{"style":312},[719],{"type":22,"value":720}," Error",{"type":17,"tag":242,"props":722,"children":723},{"style":255},[724],{"type":22,"value":320},{"type":17,"tag":242,"props":726,"children":727},{"style":266},[728],{"type":22,"value":729},"`笔记文件名不符合约定：${",{"type":17,"tag":242,"props":731,"children":732},{"style":255},[733],{"type":22,"value":419},{"type":17,"tag":242,"props":735,"children":736},{"style":266},[737],{"type":22,"value":353},{"type":17,"tag":242,"props":739,"children":740},{"style":255},[741],{"type":22,"value":742},"name",{"type":17,"tag":242,"props":744,"children":745},{"style":266},[746],{"type":22,"value":747},"}`",{"type":17,"tag":242,"props":749,"children":750},{"style":255},[751],{"type":22,"value":586},{"type":17,"tag":242,"props":753,"children":755},{"class":244,"line":754},12,[756],{"type":17,"tag":242,"props":757,"children":758},{"style":255},[759],{"type":22,"value":760},"    }\n",{"type":17,"tag":242,"props":762,"children":764},{"class":244,"line":763},13,[765,770,775,780],{"type":17,"tag":242,"props":766,"children":767},{"style":249},[768],{"type":22,"value":769},"    return",{"type":17,"tag":242,"props":771,"children":772},{"style":266},[773],{"type":22,"value":774}," `/notes/${",{"type":17,"tag":242,"props":776,"children":777},{"style":255},[778],{"type":22,"value":779},"slug",{"type":17,"tag":242,"props":781,"children":782},{"style":266},[783],{"type":22,"value":784},"}`\n",{"type":17,"tag":242,"props":786,"children":788},{"class":244,"line":787},14,[789],{"type":17,"tag":242,"props":790,"children":791},{"style":255},[792],{"type":22,"value":793},"  })\n",{"type":17,"tag":242,"props":795,"children":797},{"class":244,"line":796},15,[798],{"type":17,"tag":242,"props":799,"children":800},{"emptyLinePlaceholder":276},[801],{"type":22,"value":279},{"type":17,"tag":242,"props":803,"children":805},{"class":244,"line":804},16,[806,811,816,821],{"type":17,"tag":242,"props":807,"children":808},{"style":249},[809],{"type":22,"value":810},"export",{"type":17,"tag":242,"props":812,"children":813},{"style":249},[814],{"type":22,"value":815}," default",{"type":17,"tag":242,"props":817,"children":818},{"style":312},[819],{"type":22,"value":820}," defineNuxtConfig",{"type":17,"tag":242,"props":822,"children":823},{"style":255},[824],{"type":22,"value":825},"({\n",{"type":17,"tag":242,"props":827,"children":829},{"class":244,"line":828},17,[830],{"type":17,"tag":242,"props":831,"children":832},{"style":255},[833],{"type":22,"value":834},"  nitro: {\n",{"type":17,"tag":242,"props":836,"children":838},{"class":244,"line":837},18,[839],{"type":17,"tag":242,"props":840,"children":841},{"style":255},[842],{"type":22,"value":843},"    prerender: {\n",{"type":17,"tag":242,"props":845,"children":847},{"class":244,"line":846},19,[848,853,857],{"type":17,"tag":242,"props":849,"children":850},{"style":255},[851],{"type":22,"value":852},"      crawlLinks: ",{"type":17,"tag":242,"props":854,"children":855},{"style":301},[856],{"type":22,"value":368},{"type":17,"tag":242,"props":858,"children":859},{"style":255},[860],{"type":22,"value":861},",\n",{"type":17,"tag":242,"props":863,"children":865},{"class":244,"line":864},20,[866],{"type":17,"tag":242,"props":867,"children":868},{"style":286},[869],{"type":22,"value":870},"      // 详情缺失或渲染失败时终止构建，由发布流程保留上一次产物。\n",{"type":17,"tag":242,"props":872,"children":874},{"class":244,"line":873},21,[875,880,884],{"type":17,"tag":242,"props":876,"children":877},{"style":255},[878],{"type":22,"value":879},"      failOnError: ",{"type":17,"tag":242,"props":881,"children":882},{"style":301},[883],{"type":22,"value":368},{"type":17,"tag":242,"props":885,"children":886},{"style":255},[887],{"type":22,"value":861},{"type":17,"tag":242,"props":889,"children":891},{"class":244,"line":890},22,[892,897,902,906,911],{"type":17,"tag":242,"props":893,"children":894},{"style":255},[895],{"type":22,"value":896},"      routes: [",{"type":17,"tag":242,"props":898,"children":899},{"style":266},[900],{"type":22,"value":901},"'/notes'",{"type":17,"tag":242,"props":903,"children":904},{"style":255},[905],{"type":22,"value":344},{"type":17,"tag":242,"props":907,"children":908},{"style":249},[909],{"type":22,"value":910},"...",{"type":17,"tag":242,"props":912,"children":913},{"style":255},[914],{"type":22,"value":915},"noteRoutes]\n",{"type":17,"tag":242,"props":917,"children":919},{"class":244,"line":918},23,[920],{"type":17,"tag":242,"props":921,"children":922},{"style":255},[923],{"type":22,"value":760},{"type":17,"tag":242,"props":925,"children":927},{"class":244,"line":926},24,[928],{"type":17,"tag":242,"props":929,"children":930},{"style":255},[931],{"type":22,"value":932},"  },\n",{"type":17,"tag":242,"props":934,"children":936},{"class":244,"line":935},25,[937],{"type":17,"tag":242,"props":938,"children":939},{"style":255},[940],{"type":22,"value":941},"  content: {\n",{"type":17,"tag":242,"props":943,"children":945},{"class":244,"line":944},26,[946],{"type":17,"tag":242,"props":947,"children":948},{"style":286},[949],{"type":22,"value":950},"    // 在内容模块读入文件时排除笔记草稿，避免进入公开的静态缓存。\n",{"type":17,"tag":242,"props":952,"children":954},{"class":244,"line":953},27,[955,960,965],{"type":17,"tag":242,"props":956,"children":957},{"style":255},[958],{"type":22,"value":959},"    ignores: [",{"type":17,"tag":242,"props":961,"children":962},{"style":266},[963],{"type":22,"value":964},"'/notes/_'",{"type":17,"tag":242,"props":966,"children":967},{"style":255},[968],{"type":22,"value":969},"],\n",{"type":17,"tag":242,"props":971,"children":973},{"class":244,"line":972},28,[974,979,984],{"type":17,"tag":242,"props":975,"children":976},{"style":255},[977],{"type":22,"value":978},"    highlight: { theme: ",{"type":17,"tag":242,"props":980,"children":981},{"style":266},[982],{"type":22,"value":983},"'github-dark'",{"type":17,"tag":242,"props":985,"children":986},{"style":255},[987],{"type":22,"value":988}," }\n",{"type":17,"tag":242,"props":990,"children":992},{"class":244,"line":991},29,[993],{"type":17,"tag":242,"props":994,"children":995},{"style":255},[996],{"type":22,"value":997},"  }\n",{"type":17,"tag":242,"props":999,"children":1001},{"class":244,"line":1000},30,[1002],{"type":17,"tag":242,"props":1003,"children":1004},{"style":255},[1005],{"type":22,"value":1006},"})\n",{"type":17,"tag":34,"props":1008,"children":1010},{"id":1009},"草稿为什么会进入静态缓存",[1011],{"type":22,"value":1009},{"type":17,"tag":18,"props":1013,"children":1014},{},[1015,1017,1023,1025,1031,1033,1039,1041,1047,1049,1055],{"type":22,"value":1016},"这就是开头提到的那个问题。起初我们只在页面查询里加了 ",{"type":17,"tag":25,"props":1018,"children":1020},{"className":1019},[],[1021],{"type":22,"value":1022},".where({ _partial: false, _draft: false })",{"type":22,"value":1024},"，扫预渲染路由时也跳过了 ",{"type":17,"tag":25,"props":1026,"children":1028},{"className":1027},[],[1029],{"type":22,"value":1030},"_",{"type":22,"value":1032}," 开头的文件。按说模板既没有详情页，也不会出现在列表里。但 Nuxt Content v2 在做静态构建时，会把所有读进来的内容额外打包成一份供客户端查询的 JSON 缓存，而打包这份缓存时并不会管你在页面里写了什么 ",{"type":17,"tag":25,"props":1034,"children":1036},{"className":1035},[],[1037],{"type":22,"value":1038},".where()",{"type":22,"value":1040}," 条件。于是 ",{"type":17,"tag":25,"props":1042,"children":1044},{"className":1043},[],[1045],{"type":22,"value":1046},"content/notes/_模板.md",{"type":22,"value":1048}," 就这么原封不动地躺进了 ",{"type":17,"tag":25,"props":1050,"children":1052},{"className":1051},[],[1053],{"type":22,"value":1054},".output/public/api/_content/",{"type":22,"value":1056}," 目录下。",{"type":17,"tag":18,"props":1058,"children":1059},{},[1060,1062,1067,1069,1075,1077,1082,1084,1090,1092,1098,1100,1106,1108],{"type":22,"value":1061},"解决办法是在 ",{"type":17,"tag":25,"props":1063,"children":1065},{"className":1064},[],[1066],{"type":22,"value":209},{"type":22,"value":1068}," 里加上 ",{"type":17,"tag":25,"props":1070,"children":1072},{"className":1071},[],[1073],{"type":22,"value":1074},"content.ignores: ['/notes/_']",{"type":22,"value":1076},"，让内容模块在最开始读文件时就忽略 ",{"type":17,"tag":25,"props":1078,"children":1080},{"className":1079},[],[1081],{"type":22,"value":97},{"type":22,"value":1083}," 下所有以下划线开头的文件。注意 ",{"type":17,"tag":25,"props":1085,"children":1087},{"className":1086},[],[1088],{"type":22,"value":1089},"ignores",{"type":22,"value":1091}," 接收的字符串会被当成正则表达式去匹配路径，所以前面要带上 ",{"type":17,"tag":25,"props":1093,"children":1095},{"className":1094},[],[1096],{"type":22,"value":1097},"/notes/",{"type":22,"value":1099},"，别一竿子打翻其他目录。加上这行重新 ",{"type":17,"tag":25,"props":1101,"children":1103},{"className":1102},[],[1104],{"type":22,"value":1105},"generate",{"type":22,"value":1107}," 之后，正式文章还在，模板内容就彻底从缓存 JSON 里消失了。 ",{"type":17,"tag":62,"props":1109,"children":1112},{"href":1110,"rel":1111},"https://v2.content.nuxt.com/get-started/configuration/#ignores",[66],[1113,1115,1120],{"type":22,"value":1114},"Nuxt Content v2 的 ",{"type":17,"tag":25,"props":1116,"children":1118},{"className":1117},[],[1119],{"type":22,"value":1089},{"type":22,"value":1121}," 配置",{"type":17,"tag":18,"props":1123,"children":1124},{},[1125,1127,1133,1135,1141,1143,1149],{"type":22,"value":1126},"想自己验一下也很简单：临时建个 ",{"type":17,"tag":25,"props":1128,"children":1130},{"className":1129},[],[1131],{"type":22,"value":1132},"_draft-check.md",{"type":22,"value":1134},"，在里面写一串平时绝不会出现的特殊字符，跑完 ",{"type":17,"tag":25,"props":1136,"children":1138},{"className":1137},[],[1139],{"type":22,"value":1140},"npm run generate",{"type":22,"value":1142}," 后用下面的命令搜一下 ",{"type":17,"tag":25,"props":1144,"children":1146},{"className":1145},[],[1147],{"type":22,"value":1148},".output/public",{"type":22,"value":1150},"。只要搜出任何结果，就说明草稿还是漏进构建产物里了。",{"type":17,"tag":232,"props":1152,"children":1156},{"className":1153,"code":1154,"language":1155,"meta":8,"style":8},"language-powershell shiki shiki-themes github-dark","# 输入刚才只写在测试草稿正文里的标记，按字面值搜索。\n$draftMarker = Read-Host '输入草稿测试标记'\nrg --no-ignore --fixed-strings --files-with-matches -g '*.html' -g '*.json' -- $draftMarker .output/public\n","powershell",[1157],{"type":17,"tag":25,"props":1158,"children":1159},{"__ignoreMap":8},[1160,1168,1176],{"type":17,"tag":242,"props":1161,"children":1162},{"class":244,"line":245},[1163],{"type":17,"tag":242,"props":1164,"children":1165},{},[1166],{"type":22,"value":1167},"# 输入刚才只写在测试草稿正文里的标记，按字面值搜索。\n",{"type":17,"tag":242,"props":1169,"children":1170},{"class":244,"line":272},[1171],{"type":17,"tag":242,"props":1172,"children":1173},{},[1174],{"type":22,"value":1175},"$draftMarker = Read-Host '输入草稿测试标记'\n",{"type":17,"tag":242,"props":1177,"children":1178},{"class":244,"line":282},[1179],{"type":17,"tag":242,"props":1180,"children":1181},{},[1182],{"type":22,"value":1183},"rg --no-ignore --fixed-strings --files-with-matches -g '*.html' -g '*.json' -- $draftMarker .output/public\n",{"type":17,"tag":34,"props":1185,"children":1187},{"id":1186},"发布检查要一起看日期和页面内容",[1188],{"type":22,"value":1186},{"type":17,"tag":18,"props":1190,"children":1191},{},[1192,1194,1200,1202,1208,1210,1216,1218,1224,1226,1231,1233,1239,1241,1247,1249,1255],{"type":22,"value":1193},"为了让站点地图跟上笔记的更新日期，我们在 Nitro 的 ",{"type":17,"tag":25,"props":1195,"children":1197},{"className":1196},[],[1198],{"type":22,"value":1199},"content:file:afterParse",{"type":22,"value":1201}," 钩子里给每篇公开笔记挂上了 ",{"type":17,"tag":25,"props":1203,"children":1205},{"className":1204},[],[1206],{"type":22,"value":1207},"sitemap.loc",{"type":22,"value":1209}," 和 ",{"type":17,"tag":25,"props":1211,"children":1213},{"className":1212},[],[1214],{"type":22,"value":1215},"sitemap.lastmod",{"type":22,"value":1217},"，直接喂给现有的 sitemap 模块。",{"type":17,"tag":25,"props":1219,"children":1221},{"className":1220},[],[1222],{"type":22,"value":1223},"lastmod",{"type":22,"value":1225}," 取的就是文章头部的 ",{"type":17,"tag":25,"props":1227,"children":1229},{"className":1228},[],[1230],{"type":22,"value":58},{"type":22,"value":1232},"，详情页展示更新时间和输出 ",{"type":17,"tag":25,"props":1234,"children":1236},{"className":1235},[],[1237],{"type":22,"value":1238},"Article.dateModified",{"type":22,"value":1240}," 结构化数据也用同一个值。为了防止手误写出 ",{"type":17,"tag":25,"props":1242,"children":1244},{"className":1243},[],[1245],{"type":22,"value":1246},"2026-02-30",{"type":22,"value":1248}," 这种符合正则却不存在的日期，详情页在渲染时还会把日期转成 ",{"type":17,"tag":25,"props":1250,"children":1252},{"className":1251},[],[1253],{"type":22,"value":1254},"Date",{"type":22,"value":1256}," 对象再转回字符串比对一次，对不上就直接抛错中断构建。",{"type":17,"tag":18,"props":1258,"children":1259},{},[1260,1262,1268,1270,1275,1277,1283,1285,1291,1293],{"type":22,"value":1261},"每次打包完，校验脚本 ",{"type":17,"tag":25,"props":1263,"children":1265},{"className":1264},[],[1266],{"type":22,"value":1267},"scripts/verify-seo.mjs",{"type":22,"value":1269}," 会先从 ",{"type":17,"tag":25,"props":1271,"children":1273},{"className":1272},[],[1274],{"type":22,"value":97},{"type":22,"value":1276}," 数出应该有哪几篇正式文章，再拿着这份名单去对 ",{"type":17,"tag":25,"props":1278,"children":1280},{"className":1279},[],[1281],{"type":22,"value":1282},"sitemap.xml",{"type":22,"value":1284},"、栏目页上的链接和详情页 HTML。最后还得用手机窄屏看一眼排版——我们第一次拿真文章试排时，就发现两列时间表格在手机上会把 ",{"type":17,"tag":25,"props":1286,"children":1288},{"className":1287},[],[1289],{"type":22,"value":1290},"09:00",{"type":22,"value":1292}," 硬生生折成两行；后来把时间并进事件描述那一列，窄屏读起来才顺畅。 ",{"type":17,"tag":62,"props":1294,"children":1296},{"href":1295},"/notes/static-site-release-checks",[1297],{"type":22,"value":1298},"静态官网产物检查清单",{"type":17,"tag":1300,"props":1301,"children":1302},"style",{},[1303],{"type":22,"value":1304},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":8,"searchDepth":272,"depth":272,"links":1306},[1307,1308,1309,1310],{"id":36,"depth":272,"text":39},{"id":171,"depth":272,"text":174},{"id":1009,"depth":272,"text":1009},{"id":1186,"depth":272,"text":1186},"markdown","content:notes:nuxt-content-static-notes.md","content","notes/nuxt-content-static-notes.md","notes/nuxt-content-static-notes","md",{"loc":5,"lastmod":11},[1319,1324,1330,1336,1341,1345,1350,1354,1358,1362,1363,1368,1373,1377,1380,1384],{"_path":1320,"title":1321,"description":1322,"updated":11,"category":1323},"/notes/ai-chat-stale-replies","买家连发两条消息，AI 客服怎样避免答过时？","用一段电商客服对话解释模型结果过期的原因，给出按会话校验发送、处理人工接管和核对超时回执的办法，并附可复现的验收场景。","AI 客服",{"_path":1325,"title":1326,"description":1327,"updated":11,"category":1328,"product":1329},"/notes/ai-studio-changed-part-number","给画册加了个「一键白底」，AI 顺手把滤芯上的型号改了","翼程画册上线 AI 产品摄影棚时的真实插曲：手机拍的滤芯背景太乱，一键抠图换白底效果惊艳，放大一看，产品身上的印字怎么变成外星文了？","开发趣事","/e-album",{"_path":1331,"title":1332,"description":1333,"updated":1334,"category":1335},"/notes/auto-parts-oe-number-alias","同一个滤芯三四个 OE 号和原厂编码，仓库怎么查才不拿错货？","针对汽配和滤芯厂同一零件对应多个 OE 号、同行对照号和车型俗称的情况，拆解一码一档建重账的坑，给出唯一主编码加别名检索和带图拣货的做法。","2026-11-20","ERP 实务",{"_path":1337,"title":1338,"description":1339,"updated":1340,"category":1335},"/notes/auto-parts-returns-and-warranty","汽配退换货和三包索赔，为什么总把库存和应收账搞花？","针对汽配和滤芯批发中常见的买错退回、等价换货与质量三包索赔，拆解直接删原单和良品坏件混入库导致账实不符的原因，给出分流记账、坏件隔离和冲减应收的实操做法。","2026-11-23",{"_path":1342,"title":1343,"description":1344,"updated":11,"category":1328},"/notes/barcode-scanner-auto-enter-story","扫码枪「滴」一声之后，自己替仓管敲了个回车","记一次仓库现场调试扫码枪的乌龙：商品刚扫上去，发货单怎么自己就提交过账了？聊聊几十块钱的 USB 扫码枪在浏览器里到底干了什么。",{"_path":1346,"title":1347,"description":1348,"updated":1349,"category":1335},"/notes/customer-tiered-pricing-chaos","老客户、散客、批发商价格不一样，开单时总报串价怎么办？","针对汽配、滤芯批发中老客户协议价、等级阶梯价与散客零售价并存的接单场景，拆解靠人脑记价和翻聊天记录导致报串价的原因，说明进销存记忆客户上次售价、三级取价优先级与异常低价提醒的实操做法。","2026-11-21",{"_path":1351,"title":1352,"description":1353,"updated":11,"category":1335},"/notes/erp-opening-balance-order","进销存建账顺序搞反，为什么后面的库存和欠款全对不上？","以汽配、滤芯厂首次建账为例，算清先开单后录期初、分箱和散件混录、既是客户又是供应商拆成两条时账面怎么算错，给出建账当天就能核对的检查步。",{"_path":1355,"title":1356,"description":1357,"updated":1334,"category":1335},"/notes/filter-box-to-piece-inventory","滤芯厂按箱入库、按个出货，库存账怎么算才不乱？","结合滤芯与汽配仓库常见的整箱入库、拆箱散卖场景，拆解建两个商品档案导致串账的原因，说明基本单位、辅助单位换算与装箱数变动时的库存记账办法。",{"_path":1359,"title":1360,"description":1361,"updated":11,"category":12},"/notes/markdown-article-urls","用 Markdown 发文章，怎样保留原来的网址？","官网文章用 Markdown 文件管理。标题改了为什么网址可以不变？从文件名、标题和更新日期说起，分享让文章方便维护的做法。",{"_path":5,"title":9,"description":10,"updated":11,"category":12},{"_path":1364,"title":1365,"description":1366,"updated":11,"category":1328,"product":1367},"/notes/one-billion-order-in-demo-erp","当业务员在示例账套里开了张「一个亿」的发货单","翼程云ERP 加上「示例数据」功能后，我们在试用后台见过各种放飞自我的测试单。讲讲怎么让用户随便折腾，又能随时一键回到干净的起跑线。","/cloud-erp",{"_path":1369,"title":1370,"description":1371,"updated":11,"category":1372},"/notes/pdf-catalog-vs-e-album-search","给客户发了 30 页 PDF 报价册，为什么对方还是直接问「有没有这款」？","对比微信里发 PDF 画册与在线翻页电子画册的实际打开体验，说明图片转曲导致搜不到型号、手机端来回缩放、改价后旧文件失控三个问题及解决办法。","翼程画册",{"_path":1374,"title":1375,"description":1376,"updated":11,"category":1328,"product":1367},"/notes/receipt-printer-half-meter-blank-paper","「我就改一个字」，然后小票打印机吐了半卷白纸","记一次帮客户微调 80mm 热敏小票打印模板的踩坑：只加了行收款账号，为什么每次打单后面都跟着半米空白纸？聊聊网页打印和热敏机的纸张脾气。",{"_path":1295,"title":1378,"description":1379,"updated":11,"category":12},"静态官网构建成功了，为什么还要检查生成的 HTML？","以翼程官网的 Markdown 发文流程为例，说明如何检查静态正文、导航、规范链接与站点地图，以及哪些错误要到部署后才能发现。",{"_path":1381,"title":1382,"description":1383,"updated":11,"category":1335},"/notes/stocktake-while-shipping","仓库不停工，盘点差异应该怎么算？","用一笔先移货、后补单的算例，算清不停工盘点时的账面数量、实盘数量与真实差异，并给出仓库现场可以执行的复核步骤。",{"_path":1385,"title":1386,"description":1387,"updated":11,"category":1388},"/notes/wechat-message-to-erp-order","把微信里的报价明细粘进 ERP，自动匹配商品时要防哪些错？","拆解汽配业务员用微信接单时的常见写法，说明商品名称模糊、单位未换算、价格带错三类风险，以及 AI 识别草稿在入单前必须保留的核对环节。","AI 与开单",1795421278983]