{"_id":"@coffic/cosy-content","_rev":"30-af15bb4e9498f9f42f4c974021395300","name":"@coffic/cosy-content","dist-tags":{"latest":"0.3.8"},"versions":{"0.3.5":{"name":"@coffic/cosy-content","version":"0.3.5","keywords":["astro-integration","astro-component","withastro","astro","cosy-ui"],"author":{"url":"https://github.com/nookery","name":"nookery"},"license":"MIT","_id":"@coffic/cosy-content@0.3.5","maintainers":[{"name":"nookery","email":"nooks@qq.com"}],"homepage":"https://ui.coffic.cn","bugs":{"url":"https://github.com/CosyZone/cosy-content/issues"},"dist":{"shasum":"3a9d105c12ccd49954c0c2cacd04d4897fc53043","tarball":"https://registry.npmjs.org/@coffic/cosy-content/-/cosy-content-0.3.5.tgz","fileCount":82,"integrity":"sha512-uE7gnJ64sfZMteqcyRH+pzz0oAJk+ju/T4xMGbUpmT1+CvlYKB6QWn6LrHqbKOhMAi8rZhjFsq8lNJyIipsB3w==","signatures":[{"sig":"MEUCIQCek1eUQmOeUiQuOPA5bghdeBxqcbdG39QQUYMN7wRJkQIgVjkRkyOqb+R7UHEbSqH7D1KGy1JoKFfKVIVsC3cs27c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":218703},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"},"./schema":{"types":"./dist/schema.d.ts","import":"./dist/schema.js","require":"./dist/schema.js"}},"gitHead":"c3c6c583c56f2cea168b0a0955330ec94bd421a4","scripts":{"build":"tsc","build:dev":"tsc --sourceMap","prepublishOnly":"pnpm build"},"_npmUser":{"name":"nookery","email":"nooks@qq.com"},"repository":{"url":"git+https://github.com/CosyZone/cosy-content.git"},"_npmVersion":"10.9.2","description":"Cosy Content","directories":{},"sideEffects":false,"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.0.5","typescript":"^5.8.3","@types/node":"^24.0.14"},"peerDependencies":{"astro":"^5.12.0"},"_npmOperationalInternal":{"tmp":"tmp/cosy-content_0.3.5_1766113713566_0.9255199970464565","host":"s3://npm-registry-packages-npm-production"}},"0.3.8":{"name":"@coffic/cosy-content","version":"0.3.8","description":"Cosy Content","author":{"name":"nookery","url":"https://github.com/nookery"},"repository":{"url":"git+https://github.com/CosyZone/cosy-content.git"},"license":"MIT","keywords":["astro-integration","astro-component","withastro","astro","cosy-ui"],"homepage":"https://ui.coffic.cn/en","publishConfig":{"access":"public"},"sideEffects":false,"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js","types":"./dist/index.d.ts"},"./schema":{"import":"./dist/schema.js","require":"./dist/schema.js","types":"./dist/schema.d.ts"}},"scripts":{"build":"tsc","build:dev":"tsc --sourceMap","prepublishOnly":"pnpm build"},"type":"module","peerDependencies":{"astro":"^5.12.0"},"devDependencies":{"@types/node":"^24.0.14","typescript":"^5.8.3","zod":"^4.0.5"},"gitHead":"2d2d2c26c314dec8b9ad87bec7fa7d0571e655bd","_id":"@coffic/cosy-content@0.3.8","bugs":{"url":"https://github.com/CosyZone/cosy-content/issues"},"_nodeVersion":"23.11.1","_npmVersion":"11.7.0","dist":{"integrity":"sha512-32Sexpp30/04wJ7X1UbIxcBzJSN06RmnaAnU6MFsLj/z7kdcjy5e4876Hrwt68aiPqpaHQ7qi7S34JN3k0lTig==","shasum":"35cc945b1ae83e85a73a190152e19e2c04e4d81f","tarball":"https://registry.npmjs.org/@coffic/cosy-content/-/cosy-content-0.3.8.tgz","fileCount":82,"unpackedSize":222017,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@coffic%2fcosy-content@0.3.8","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIA1yhWBrYx19NQbEAjMBhX3wVP5V1NEgUHsVTYJrzsM6AiAt1Rk5fqVq9j898dZfMj+tPgNRtNz1yn69FnjfAJ5tLg=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ce2e544c-2aff-4eaf-80a5-1a46e90527cd"}},"directories":{},"maintainers":[{"name":"nookery","email":"nooks@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cosy-content_0.3.8_1766116909802_0.7303476044983905"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-19T03:08:33.461Z","modified":"2025-12-19T04:01:50.409Z","0.1.1":"2025-07-17T13:32:47.483Z","0.2.1":"2025-07-17T14:21:03.945Z","0.2.2":"2025-07-17T14:29:54.203Z","0.2.3":"2025-07-17T14:42:13.128Z","0.2.4":"2025-07-18T00:51:16.556Z","0.2.5":"2025-07-18T02:07:17.336Z","0.2.6":"2025-07-18T02:13:33.475Z","0.2.8":"2025-07-18T02:29:22.364Z","0.2.9":"2025-07-18T03:02:07.617Z","0.2.10":"2025-07-18T05:20:24.998Z","0.2.11":"2025-07-18T06:18:54.053Z","0.2.12":"2025-07-28T13:52:27.979Z","0.2.13":"2025-08-02T09:40:09.459Z","0.2.14":"2025-08-02T11:37:34.693Z","0.2.15":"2025-08-02T12:42:02.551Z","0.2.16":"2025-08-02T12:55:26.480Z","0.2.18":"2025-08-02T13:20:20.464Z","0.2.19":"2025-08-02T13:22:50.079Z","0.2.20":"2025-08-02T13:41:16.478Z","0.2.21":"2025-08-02T13:58:31.687Z","0.2.22":"2025-08-04T08:05:47.181Z","0.2.23":"2025-08-04T10:20:15.696Z","0.2.24":"2025-08-04T10:24:26.828Z","0.2.25":"2025-08-04T10:36:40.170Z","0.2.26":"2025-09-12T15:51:28.180Z","0.2.27":"2025-09-15T01:36:18.972Z","0.2.28":"2025-11-05T09:07:28.234Z","0.3.5":"2025-12-19T03:08:33.730Z","0.3.8":"2025-12-19T04:01:49.988Z"},"bugs":{"url":"https://github.com/CosyZone/cosy-content/issues"},"author":{"name":"nookery","url":"https://github.com/nookery"},"license":"MIT","homepage":"https://ui.coffic.cn/en","keywords":["astro-integration","astro-component","withastro","astro","cosy-ui"],"repository":{"url":"git+https://github.com/CosyZone/cosy-content.git"},"description":"Cosy Content","maintainers":[{"name":"nookery","email":"nooks@qq.com"}],"readme":"# Cosy Content\n\n[![English](https://img.shields.io/badge/English-violet)](README.md) [![简体中文](https://img.shields.io/badge/中文文档-gray)](docs/README-zh.md) [![Release](https://img.shields.io/github/v/release/cofficlab/cosy-ui?style=flat-square&logo=github&color=blue)](https://github.com/yuaotian/go-cursor-help/releases/latest) [![DEV](https://img.shields.io/badge/DEV-gray)](README-dev.md) [![NPM](https://img.shields.io/badge/NPM-orange)](https://www.npmjs.com/package/@coffic/cosy-ui) ![NPM Downloads](https://img.shields.io/npm/dm/%40coffic%2Fcosy-ui) ![NPM Version](https://img.shields.io/npm/v/%40coffic%2Fcosy-ui) [![Coffic](https://img.shields.io/badge/Coffic-green)](https://coffic.cn) [![Maintainer](https://img.shields.io/badge/Maintainer-blue)](https://github.com/nookery) ![GitHub License](https://img.shields.io/github/license/cofficlab/cosy-ui)\n\n一个用于管理多种类型内容的 TypeScript 库，支持博客、课程、实验、课程、手册等多种内容类型。\n\n## 功能特性\n\n- **多种内容类型支持**：博客、课程、实验、故事、手册等\n- **多语言支持**：内置中文和英文支持\n- **类型安全**：完整的 TypeScript 类型定义\n- **Schema 扩展**：支持自定义字段，保持类型安全\n- **灵活的内容管理**：支持层级结构、标签、分类等\n- **SEO 友好**：内置 SEO 优化功能\n- **易于扩展**：模块化设计，易于添加新的内容类型\n\n## 内容类型\n\n### BlogDoc - 博客文档\n\n适合发布独立的博客文章，支持标签、分类、作者等信息。\n\n### CourseDoc - 课程文档\n\n适合组织成体系的课程内容，支持多级章节结构。\n\n### LessonDoc - 课程文档\n\n适合单个课程的详细教程，支持步骤化的学习内容。\n\n### ExperimentDoc - 实验文档\n\n适合记录技术实验和探索，支持实验过程和结果展示。支持草稿（draft）、隐藏（hidden）、徽章（badge）、排序（order）、标签（tags）等属性，与课程文档具有相同的属性支持。\n\n### ManualDoc - 手册文档\n\n适合展示成体系的文档，如产品用户手册、技术框架文档等。每个仓库只有一个完整的手册，按章节组织。\n\n### StoryDoc - 故事文档\n\n适合绘本、故事等内容，支持多级章节结构和自定义字段扩展。\n\n## 目录结构\n\n```text\ncontent/\n├── blogs/          # 博客文章\n├── courses/        # 课程内容\n├── lessons/        # 课程教程\n├── experiments/    # 实验记录\n├── stories/        # 故事内容\n├── manuals/        # 手册文档\n└── meta/           # 元数据\n```\n\n## 快速开始\n\n### 安装\n\n```bash\nnpm install @coffic/cosy-content\n```\n\n### 基本使用\n\n```typescript\nimport { blogRepo, courseRepo, experimentRepo, storyRepo, manualRepo } from '@coffic/cosy-content';\n\n// 获取博客文章\nconst blogs = await blogRepo.allBlogsByLang('zh-cn');\n\n// 获取课程内容\nconst courses = await courseRepo.allCoursesByLang('zh-cn');\n\n// 获取实验内容\nconst experiments = await experimentRepo.allExperiments('zh-cn');\n\n// 获取故事内容\nconst stories = await storyRepo.allStoriesByLang('zh-cn');\n\n// 获取手册内容\nconst manuals = await manualRepo.allManualsByLang('zh-cn');\n```\n\n## API 参考\n\n### BlogRepo\n\n- `allBlogsByLang(lang: string)` - 获取指定语言的所有博客\n- `getFamousBlogs(lang: string, count?: number)` - 获取精选博客\n- `getBlogsWithTag(lang: string, tag: string)` - 根据标签获取博客\n\n### CourseRepo\n\n- `allCoursesByLang(lang: string)` - 获取指定语言的所有课程\n- `getFamousCourses(lang: string, count?: number)` - 获取精选课程\n- `getCoursesWithTag(lang: string, tag: string)` - 根据标签获取课程\n\n### ExperimentRepo\n\n- `allExperiments(lang: string)` - 获取指定语言的所有实验\n- `find(id: string)` - 根据 ID 查找单个实验文档\n- `getChildren(id: string)` - 获取指定实验的子文档（按 order 排序）\n\n### ExperimentDoc\n\n实验文档类提供以下方法：\n\n- `getOrder()` - 获取排序值\n- `getBadge()` - 获取徽章文本\n- `getTags()` - 获取标签数组\n- `isDraft()` - 判断是否为草稿\n- `isHidden()` - 判断是否隐藏\n- `isNotHidden()` - 判断是否不隐藏\n- `hasTag(tag: string)` - 判断是否包含某个标签\n- `hasBadge()` - 判断是否有徽章\n- `getChildren()` - 获取子文档（按 order 排序，自动过滤 hidden 项）\n- `toSidebarItem()` - 转换为侧边栏项（支持 badge 显示）\n\n### StoryRepo\n\n- `allStoriesByLang(lang: string)` - 获取指定语言的所有故事\n- `getFamousStories(lang: string, count?: number)` - 获取精选故事\n- `getStoriesWithTag(lang: string, tag: string)` - 根据标签获取故事\n\n### ManualRepo\n\n- `allManualsByLang(lang: string)` - 获取指定语言的所有手册章节\n- `getImportantManuals(lang: string, count?: number)` - 获取重要章节\n- `getManualsWithTag(lang: string, tag: string)` - 根据标签获取手册内容\n- `getManualsByCategory(lang: string, category: string)` - 根据分类获取手册内容\n- `getManualStructure(lang: string)` - 获取手册的完整目录结构\n\n## 配置\n\n在 `content.config.ts` 中配置内容集合：\n\n```typescript\nimport {\n  makeBlogCollection,\n  makeCourseCollection,\n  makeExperimentCollection,\n  makeStoryCollection,\n  makeManualCollection,\n} from '@coffic/cosy-content/schema';\n\nexport const collections = {\n  blogs: makeBlogCollection('./content/blogs'),\n  courses: makeCourseCollection('./content/courses'),\n  experiments: makeExperimentCollection('./content/experiments'),\n  stories: makeStoryCollection('./content/stories'),\n  manuals: makeManualCollection('./content/manuals'),\n};\n```\n\n### Schema 扩展\n\n支持为任何集合添加自定义字段：\n\n```typescript\nimport { z } from 'astro:content';\nimport { makeStoryCollection } from '@coffic/cosy-content/schema';\n\nexport const collections = {\n  stories: makeStoryCollection('./content/stories', {\n    // 自定义字段\n    background: z.string().optional(),\n    pageAspectRatio: z.number().optional(),\n    textBoxes: z.array(z.object({\n      slot: z.string(),\n      top: z.number(),\n      left: z.number(),\n      width: z.number(),\n      bg: z.string(),\n      content: z.string(),\n    })).optional(),\n  }),\n};\n```\n\n## 开发\n\n### 构建\n\n```bash\nnpm run build\n```\n\n### 测试\n\n```bash\nnpm run test\n```\n\n## 许可证\n\nMIT License\n","readmeFilename":"README.md"}