{"id":17297068,"url":"https://github.com/3lang3/vite-plugin-react-mdoc","last_synced_at":"2025-03-26T20:44:19.344Z","repository":{"id":44799021,"uuid":"442634894","full_name":"3lang3/vite-plugin-react-mdoc","owner":"3lang3","description":"import markdown files in vite and get code block.","archived":false,"fork":false,"pushed_at":"2022-02-23T13:21:38.000Z","size":715,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T02:41:24.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/3lang3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-29T02:09:36.000Z","updated_at":"2022-05-18T16:40:49.000Z","dependencies_parsed_at":"2022-09-19T05:11:12.135Z","dependency_job_id":null,"html_url":"https://github.com/3lang3/vite-plugin-react-mdoc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3lang3%2Fvite-plugin-react-mdoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3lang3%2Fvite-plugin-react-mdoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3lang3%2Fvite-plugin-react-mdoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3lang3%2Fvite-plugin-react-mdoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3lang3","download_url":"https://codeload.github.com/3lang3/vite-plugin-react-mdoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245734007,"owners_count":20663621,"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":[],"created_at":"2024-10-15T11:14:41.036Z","updated_at":"2025-03-26T20:44:19.323Z","avatar_url":"https://github.com/3lang3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-mdoc\n\nA plugin enables you to import a Markdown file as various formats on your [vite](https://github.com/vitejs/vite) project inspirt by [dumi](https://github.com/umijs/dumi).\n\n## Setup\n\n```\nnpm i -D vite-plugin-react-mdoc\n```\n\n### Config\n\n```js\nconst mdoc = require('vite-plugin-react-mdoc');\n\nmodule.exports = {\n  plugins: [mdoc(options)],\n};\n```\n\nThen you can import front matter attributes from `.md` file as default.\n\n````md\n# Hello world\n\n```tsx\nimport React from 'react';\n\nexport default () =\u003e {\n  const [count, setCount] = React.useState(0);\n  return \u003cbutton onClick={() =\u003e setCount(v =\u003e v + 1)}\u003ecount: {count}\u003c/button\u003e;\n};\n```\n\n````\n\n\n```tsx\nimport { MdContent, MdDemos } from './doc.md';\n````\n\n### Type declarations\n\nIn TypeScript project, need to declare typedefs for `.md` file as you need.\n\n```ts\ndeclare module '*.md' {\n  // When \"Mode.React\" is requested. VFC could take a generic like React.VFC\u003c{ MyComponent: TypeOfMyComponent }\u003e\n  import React from 'react';\n  type MDocPreviewerProps = {\n    code: string;\n    lang: string;\n    key: string;\n    dependencies: Record\u003c\n      string,\n      {\n        type: string;\n        value: string;\n        css: boolean;\n      }\n    \u003e;\n    meta: Record\u003cstring, any\u003e;\n    children: React.ReactNode;\n  }\n\n  const MdContent: React.VFC\u003c{\n    previewer?: (props: MDocPreviewerProps) =\u003e React.ReactNode;\n  }\u003e;\n  const MdDemos: ({ Component: React.VFC; key: string } \u0026 Record\u003cstring, any\u003e)[];\n\n  const frontmatter: Record\u003cstring, string\u003e;\n\n  const slugs: { depth: number; text: string; id: string; }[];\n\n  // Modify below per your usage\n  export { MdContent, MdDemos, frontmatter, slugs };\n}\n```\n\nSave as `vite.d.ts` for instance.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3lang3%2Fvite-plugin-react-mdoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3lang3%2Fvite-plugin-react-mdoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3lang3%2Fvite-plugin-react-mdoc/lists"}