{"id":26284606,"url":"https://github.com/maxchang3/newmd","last_synced_at":"2025-05-07T12:25:38.819Z","repository":{"id":281815194,"uuid":"846051643","full_name":"maxchang3/newmd","owner":"maxchang3","description":"A CLI tool that creates markdown files with frontmatter using a Zod schema.","archived":false,"fork":false,"pushed_at":"2025-04-29T14:14:27.000Z","size":411,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T14:16:59.338Z","etag":null,"topics":["astro","cli-tool","frontmatter","markdown","zod"],"latest_commit_sha":null,"homepage":"","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/maxchang3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-22T12:49:11.000Z","updated_at":"2025-04-29T14:14:27.000Z","dependencies_parsed_at":"2025-03-11T09:44:45.736Z","dependency_job_id":"e6befe56-4674-4312-ba2d-923ffc7e4ab6","html_url":"https://github.com/maxchang3/newmd","commit_stats":null,"previous_names":["maxchang3/newmd"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxchang3%2Fnewmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxchang3%2Fnewmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxchang3%2Fnewmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxchang3%2Fnewmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxchang3","download_url":"https://codeload.github.com/maxchang3/newmd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252875257,"owners_count":21817990,"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":["astro","cli-tool","frontmatter","markdown","zod"],"created_at":"2025-03-14T18:36:48.352Z","updated_at":"2025-05-07T12:25:38.796Z","avatar_url":"https://github.com/maxchang3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e➕ newmd \u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eA CLI tool that creates markdown files with frontmatter using a Zod schema.\u003c/p\u003e\n\n\u003cpre align=\"center\"\u003e\n  npx newmd blog \"Hello World\"\n\u003c/pre\u003e\n\n\u003csup\u003e\\* `blog` is the default schema with some fields. You can define your own schema in the config file.\u003c/sup\u003e\n\n[![npm](https://img.shields.io/npm/v/newmd.svg?style=flat-square\u0026color=444)](https://www.npmjs.com/package/newmd)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/maxchang3/newmd/ci.yml?style=flat-square\u0026label=CI)](https://github.com/maxchang3/newmd/actions)\n[![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat-square\u0026logo=biome)](https://biomejs.dev)\n[![License](https://img.shields.io/github/license/maxchang3/newmd?style=flat-square)](LICENSE)\n\n## Usage\n\n## CLI\n\nRun the following command in your terminal:\n\n```sh\nnpx newmd blog \"Hello World\"\n```\n\nor using `pnpx`(`pnpm dlx`):\n\n```sh\npnpx newmd blog \"Hello World\"\n```\n\nWill create a markdown file with the following content:\n\n```md\n---\ntitle: Hello World\ndescription: ''\npubDate: 2025-03-09T01:57:00.000Z\n---\n```\n\n\u003csup\u003e\\* The `pubDate` field will be filled with `new Date()`.\u003c/sup\u003e\n\nYou can install it globally for convenience.\n\n### Options\n\nSee `newmd --help` for more details, following is a brief description.\n\n\u003cdetails\u003e\n\n```sh\nnewmd \u003cschemaName\u003e \u003ctitle\u003e\n```\n\n- `--content \u003cvalue\u003e` Set the content of the markdown file\n- `--path \u003cvalue\u003e` Set the output directory\n- `--slug \u003cvalue\u003e` Set the slug for the filename, if not provided, it will be generated from the slugified title.\n- `--cwd \u003cvalue\u003e` Set the current working directory\n- `--toml` Whether to use TOML format for frontmatter, default is `false`\n- `--overwrite` Whether to overwrite the existing file, default is `false`\n\n\u003c/details\u003e\n\n## Config file\n\nYou need to create a config file to define the schemas for the frontmatter.\n\nThe config structure and default values are as follows:\n\n```ts\n// newmd.config.[js,mjs,ts]\nimport { defineConfig, z } from 'newmd'\n\nexport default defineConfig({\n    // The format of the frontmatter.\n    format: 'yaml',\n    // Root path for the markdown file.\n    path: '.',\n    // Schemas for the frontmatter.\n    schemas: {\n        blog: z.object({\n            title: z.string(),\n            description: z.string().optional(),\n            pubDate: z.coerce.date(),\n            updatedDate: z.coerce.date().optional(),\n        }),\n    },\n})\n```\n\n## Integration\n\n### With [Astro](https://astro.build/)\n\n\u003cdetails\u003e\n\nSay you have this content config file:\n\n```ts\n// src/content.config.ts\nimport { glob } from 'astro/loaders'\nimport { defineCollection, z } from 'astro:content'\n\nconst blog = defineCollection({\n    loader: glob({ pattern: '**/*.md', base: './src/data/blog' }),\n    schema: z.object({\n        title: z.string(),\n        permalink: z.string().optional(),\n    }),\n})\n\nexport const collections = { blog }\n```\n\nYou can create a newmd config file like this:\n\n```ts\n// newmd.config.ts\nimport { defineConfig, z } from 'newmd'\n\nexport default defineConfig({\n    // Corresponding to the `base` option in the content config.\n    path: './src/data/blog',\n    schemas: { // Copy the schema from the content config.\n        blog: z.object({\n            title: z.string(),\n            description: z.string().optional(),\n            pubDate: z.coerce.date(),\n            updatedDate: z.coerce.date().optional(),\n        }),\n    },\n})\n```\n\nNow you can use the same schema to create markdown files with frontmatter by running `npx newmd blog \"Hello World\"`.\n\n\u003c/details\u003e\n\n## Credits\n\nThis project won't be possible without [@toiroakr](https://github.com/toiroakr)'s [zod-empty](https://github.com/toiroakr/zod-empty/) and other open-source projects.\n\n## License\n\n[MIT](./LICENSE) License © 2024-PRESENT [Max Chang](https://github.com/maxchang3)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxchang3%2Fnewmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxchang3%2Fnewmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxchang3%2Fnewmd/lists"}