{"id":15848583,"url":"https://github.com/kfirfitousi/contentlayer-mock","last_synced_at":"2026-05-12T07:35:05.748Z","repository":{"id":65231631,"uuid":"587778901","full_name":"kfirfitousi/contentlayer-mock","owner":"kfirfitousi","description":"Generate typed mocks for Contentlayer documents","archived":false,"fork":false,"pushed_at":"2023-01-15T14:11:35.000Z","size":82,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T15:17:32.996Z","etag":null,"topics":["contentlayer","markdown","mdx","mock","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/contentlayer-mock","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kfirfitousi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-11T15:10:09.000Z","updated_at":"2023-10-28T08:05:41.000Z","dependencies_parsed_at":"2023-01-15T18:00:27.025Z","dependency_job_id":null,"html_url":"https://github.com/kfirfitousi/contentlayer-mock","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfirfitousi%2Fcontentlayer-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfirfitousi%2Fcontentlayer-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfirfitousi%2Fcontentlayer-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfirfitousi%2Fcontentlayer-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfirfitousi","download_url":"https://codeload.github.com/kfirfitousi/contentlayer-mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246684823,"owners_count":20817506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contentlayer","markdown","mdx","mock","typescript"],"created_at":"2024-10-05T18:04:03.091Z","updated_at":"2026-05-12T07:35:00.722Z","avatar_url":"https://github.com/kfirfitousi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# contentlayer-mock\n\nGenerate typed mocks for [Contentlayer](https://github.com/contentlayerdev/contentlayer) documents.\n\n![npm version](https://img.shields.io/npm/v/contentlayer-mock?style=flat-square)\n![size](https://img.shields.io/bundlephobia/min/contentlayer-mock?style=flat-square)\n\n## Usage\n\n### Generate a mocked document\n\n`dummy` generates a single mocked document. The argument `properties` must contain all required fields of the document type.\n\n```ts\nimport { type Post } from \"contentlayer/generated\";\nimport { dummy } from \"contentlayer-mock\";\n\nconst dummyPost = dummy\u003cPost\u003e({\n  title: \"Dummy Post\",\n  description: \"This is a dummy post\",\n});\n\n// equivalent to\n\nconst dummyPost: Post = {\n  _id: \"dummy\",\n  _raw: {\n    contentType: \"mdx\",\n    flattenedPath: \"posts/dummy\",\n    sourceFileDir: \"posts\",\n    sourceFileName: \"dummy-post.mdx\",\n    sourceFilePath: \"posts/dummy-post.mdx\",\n  },\n  body: {\n    code: \"\",\n    raw: \"dummy document raw content\",\n  },\n  type: \"Post\",\n  title: \"Dummy Post\",\n  description: \"This is a dummy post\",\n};\n```\n\n`properties` can also be used to overwrite the default properties of the document.\n\n```ts\nconst dummyPost = dummy\u003cPost\u003e({\n  title: \"Dummy Post\",\n  description: \"This is a dummy post\",\n  _id: \"custom-id\",\n  body: {\n    raw: \"custom raw content\",\n  },\n});\n\ndummyPost._id; // \"custom-id\"\ndummyPost.body.raw; // \"custom raw content\"\n```\n\n### Generate an array of mocked documents\n\n`dummyArray` generates an array of mocked documents. The first argument, `length`, is the number of documents to generate. The second argument, `properties`, must contain all required fields of the document type.\n\n```ts\nimport { type Post } from \"contentlayer/generated\";\nimport { dummyArray } from \"contentlayer-mock\";\n\nconst dummyPosts = dummyArray\u003cPost\u003e(10, {\n  title: \"Dummy Post\",\n  description: \"This is a dummy post\",\n});\n```\n\n`properties` can also be used to overwrite the default properties of the documents.\n\n```ts\nconst dummyPosts = dummyArray\u003cPost\u003e(10, {\n  title: \"Dummy Post\",\n  description: \"This is a dummy post\",\n  _id: \"custom-id\",\n  _raw: {\n    flattenedPath: \"posts/custom-id\",\n  },\n});\n```\n\nYou can also pass a function to `properties` to generate different values for each document.\n\n```ts\nconst dummyPosts = dummyArray\u003cPost\u003e(10, (index) =\u003e ({\n  title: `Dummy Post ${index}`,\n  description: `This is a dummy post ${index}`,\n  _id: `custom-id-${index}`,\n}));\n```\n\n## Limitations\n\nCurrently only supports `mdx` documents.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfirfitousi%2Fcontentlayer-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfirfitousi%2Fcontentlayer-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfirfitousi%2Fcontentlayer-mock/lists"}