{"id":25656400,"url":"https://github.com/dogma-io/babel-plugin-react-code-block","last_synced_at":"2025-11-14T19:01:29.804Z","repository":{"id":31501264,"uuid":"116583652","full_name":"dogma-io/babel-plugin-react-code-block","owner":"dogma-io","description":"Display React functional examples with source code.","archived":false,"fork":false,"pushed_at":"2023-01-04T21:50:48.000Z","size":1589,"stargazers_count":1,"open_issues_count":17,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T11:07:39.820Z","etag":null,"topics":["babel","babel-plugin","block","code","example","react","sample","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dogma-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-07T17:08:37.000Z","updated_at":"2020-01-19T16:17:49.000Z","dependencies_parsed_at":"2023-01-14T19:15:47.631Z","dependency_job_id":null,"html_url":"https://github.com/dogma-io/babel-plugin-react-code-block","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogma-io%2Fbabel-plugin-react-code-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogma-io%2Fbabel-plugin-react-code-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogma-io%2Fbabel-plugin-react-code-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogma-io%2Fbabel-plugin-react-code-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dogma-io","download_url":"https://codeload.github.com/dogma-io/babel-plugin-react-code-block/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240390498,"owners_count":19793780,"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":["babel","babel-plugin","block","code","example","react","sample","tutorial"],"created_at":"2025-02-23T22:32:51.082Z","updated_at":"2025-11-14T19:01:24.784Z","avatar_url":"https://github.com/dogma-io.png","language":"JavaScript","readme":"# babel-plugin-react-code-block [![NPM][npm-img]][npm-url] [![Coverage][cov-img]][cov-url]\n\nDisplay React functional examples with source code.\n\n## Table of Contents\n\n*   [Installation](#installation)\n*   [Documentation](#documentation)\n*   [Code of Conduct](#code-of-conduct)\n*   [Contributing](#contributing)\n*   [License](#license)\n\n## Installation\n\n**npm**\n\n```bash\nnpm install babel-plugin-react-code-block\n```\n\n**yarn**\n\n```bash\nyarn add babel-plugin-react-code-block\n```\n\n## Documentation\n\nCreate a code block component with a `code` property, which will be populated by this plugin:\n```js\nimport React from 'react'\n\nexport default ({children, code}) =\u003e {\n  return (\n    \u003cdiv\u003e\n      {children}\n      \u003ccode\u003e{code}\u003c/code\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n\u003e Note: In the above example component children is the passed in JSX that you want to render as a demo and code is the passed in JSX converted to a string so you can also print the code sample (which is run through prettier to make it look aesthetically pleasing).\n\nIn your Babel configuration include:\n```js\nmodule.exports = {\n  \"plugins\": [\n    [\n      \"babel-plugin-react-code-block\",\n      {\n        \"component\": \"CodeBlock\",\n      },\n    ],\n  ],\n}\n```\n\n\u003e Note: In the above configuration change `CodeBlock` to the name of your code block component. This plugin will simply apply the transform to any JSX elements matching the component name.\n\n## Code of Conduct\n\nPlease see the [code of conduct](CODE_OF_CONDUCT.md).\n\n## Contributing\n\nPlease see the [contributing guide](CONTRIBUTING.md).\n\n## License\n\n[MIT](LICENSE.md)\n\n[cov-img]: https://img.shields.io/codecov/c/github/dogma-io/babel-plugin-react-code-block.svg \"Code Coverage\"\n[cov-url]: https://codecov.io/gh/dogma-io/babel-plugin-react-code-block\n\n[npm-img]: https://img.shields.io/npm/v/babel-plugin-react-code-block.svg \"NPM Version\"\n[npm-url]: https://www.npmjs.com/package/babel-plugin-react-code-block\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogma-io%2Fbabel-plugin-react-code-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdogma-io%2Fbabel-plugin-react-code-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogma-io%2Fbabel-plugin-react-code-block/lists"}