用途:为 Nuxt 4 项目中使用 @nuxt/content 模块提供专家级实践指导,适用内容目录管理、Markdown 文章、frontmatter 与内容渲染。\n\n主要能力:Nuxt 4 采用 app/ 目录结构,content/ 仍保留在项目根目录;支持内容目录层级、_dir.yml 目录元数据、数字前缀排序(前缀从 URL 中剥离)、kebab-case 命名。Frontmatter 可定义 title、description、estimatedMinutes、difficulty、learningObjectives、quiz(含 passingScore、questions 等)。查询方面可用 queryContent() 获取单文档(findOne)、目录下全部文档(find 配合 where、sort)、导航树(fetchContentNavigation)、前后篇(findSurround),以及按字段过滤与 count() 计数。渲染可用 ContentRenderer 或 ContentDoc(含 not-found、empty 插槽),并读取 body.toc.links 生成目录。\n\n使用方式:在 nuxt.config.ts 中配置 compatibilityVersion: 4、modules 与 content 选项(highlight、markdown.toc);查询务必用 useAsyncData 以保证 SSR 兼容;动态路由从 route.params 拼出内容路径后查询。\n\n限制与注意:内部内容路径用 _path 而非 path;数字前缀会从 URL 剥离;$exists 用于检查字段存在;Prose 样式可搭配 Tailwind Typography。价格、平台、更多细节暂未提供。
nuxt-content
通用与其它
更新于 10-16 05:46