{"name":"gatsby-remark-component","description":"When you use a React component in your markdown, it will insert it as a div instead of a p","version":"1.0.0","author":{"name":"Hebilicious","email":"xsh4k3@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/hebilicious/gatsby-remark-component.git"},"dependencies":{"unist-util-visit":"^1.1.1"},"keywords":["gatsby","gatsby-plugin","gatsby-transformer-remark","component","remark","markdown"],"license":"MIT","main":"index.js","gitHead":"a85dc323ac827b6d3c2cd80baa3aca8980287c63","bugs":{"url":"https://github.com/hebilicious/gatsby-remark-component/issues"},"homepage":"https://github.com/hebilicious/gatsby-remark-component#readme","_id":"gatsby-remark-component@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"hebilicious","email":"xsh4k3@gmail.com"},"dist":{"integrity":"sha512-ZfdADTx3HDxZkmcLfSEqy9EbY/RVDM+y8DskYx0VfBUf9Zqe/ZZjTACwtk5m5t51hhQ4L9GiKYUkNKjAToxrzA==","shasum":"47142c754951fa33eb0f651a5901d6a038dc9382","tarball":"http://registry-npm.ywwl.com/gatsby-remark-component/download/gatsby-remark-component-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG1a/0wNI84afdv3RiNfZ0CLh0xLvWswoYNfytkcV0rnAiEAyaHM2Je5Xb2HdTjrMjyPP3dGyu3lJJ2eIhutXiJuSZw="}],"size":1454,"noattachment":false,"key":"/gatsby-remark-component/-/gatsby-remark-component-1.0.0.tgz"},"maintainers":[{"name":"hebilicious","email":"xsh4k3@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-remark-component-1.0.0.tgz_1517729334997_0.08762029907666147"},"directories":{},"readme":"# Gatsby Remark Component [![Build Status](https://travis-ci.org/Hebilicious/gatsby-remark-component.svg?branch=master)](https://travis-ci.org/Hebilicious/gatsby-remark-component) [![npm version](https://badge.fury.io/js/gatsby-remark-component.svg)](https://badge.fury.io/js/gatsby-remark-component)\n\nA gatsby-transformer-remark plugin that change the AST node parent of a custom component to a div.\n\n> * [Gatsby](https://www.gatsbyjs.org/)\n> * [gatsby-transformer-remark](https://www.gatsbyjs.org/packages/gatsby-transformer-remark/)\n\n## Install\n\n```bash\nyarn add gatsby-transformer-remark gatsby-remark-component\n```\n\n## Release Notes\n\n> v 1.1\n\n* New configuration options!\n* Can now auto-detect your custom components.\n\n## How to use\n\n> Read the great custom component article on the official gatsby remark blog [here](https://using-remark.gatsbyjs.org/custom-components/).\n\nThis is the base settings, your components inside your markdown will be auto-detected.\n\n```js\n//In your gatsby-config.js ...\nplugins: [\n  {\n    resolve: \"gatsby-transformer-remark\",\n    options: {\n      plugins: [\"gatsby-remark-component\"]\n    }\n  }\n]\n```\n\nYou can explicitly declare the name of the components if you want to be strict. (it will disable the auto-detection\n)\n\n```js\nplugins: [\n  {\n    resolve: \"gatsby-transformer-remark\",\n    options: {\n      plugins: [\n        {\n          resolve: \"gatsby-remark-component\",\n          options: { components: [\"my-component\", \"other-component\"] }\n        }\n      ]\n    }\n  }\n]\n```\n\nWhen you start gatsby, your queries will be built from your components, and gatsby-remark-components will update the AST tree.\n\nThis will convert this graphql result:\n\n```json\n//...\n{\n  \"type\": \"element\",\n  \"tagName\": \"p\",\n  \"properties\": {},\n  \"children\": [\n    {\n      \"type\": \"element\",\n      \"tagName\": \"my-component\",\n      \"properties\": {},\n      \"children\": []\n    }\n  ]\n}\n```\n\nTo this:\n\n```json\n//...\n//Notice the tag name\n{\n  \"type\": \"element\",\n  \"tagName\": \"div\",\n  \"properties\": {},\n  \"children\": [\n    {\n      \"type\": \"element\",\n      \"tagName\": \"my-component\",\n      \"properties\": {},\n      \"children\": []\n    }\n  ]\n}\n```\n\nNow in your markdown template you can do:\n\n```jsx\nimport rehypeReact from \"rehype-react\"\nimport { MyComponent } from \"../pages/my-component\"\n\nconst renderAst = new rehypeReact({\n  createElement: React.createElement,\n  components: { \"my-component\": MyComponent }\n}).Compiler\n```\n\nReplace :\n\n```jsx\n<div dangerouslySetInnerHTML={{ __html: post.html }} />\n```\n\nby:\n\n```jsx\n<div>{renderAst(post.htmlAst)}</div>\n```\n\nAnd in your page query ... :\n\n```jsx\n//...\nmarkdownRemark(fields: { slug: { eq: $slug } }) {\n htmlAst // previously `html`\n\n //other fields...\n}\n//...\n```\n\nNow in your markdown you can do:\n\n```md\n# Some Title\n\nSome text\n\n<my-component></my-component>\n```\n\nThis will render your component without any validateDOMNesting warning.\n","publish_time":1517729335889,"_cnpm_publish_time":1517729335889,"dist-tags":{"latest":"1.1.3"}}