{"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.1.1","author":{"name":"Hebilicious","email":"xsh4k3@gmail.com"},"main":"lib.js","files":["src"],"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"],"scripts":{"pretest":"npm run build","test":"jest","dev":"rollup -c --watch","build":"rollup -c","prepublish":"npm run test"},"license":"MIT","devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-jest":"^22.1.0","babel-plugin-external-helpers":"^6.22.0","babel-preset-env":"^1.6.1","jest":"^22.1.4","rollup":"^0.55.3","remark":"^9.0.0","rollup-plugin-babel":"^3.0.3","rollup-plugin-node-resolve":"^3.0.2"},"gitHead":"213871cb20d564d25ef36818780673706e7b9fbe","bugs":{"url":"https://github.com/hebilicious/gatsby-remark-component/issues"},"homepage":"https://github.com/hebilicious/gatsby-remark-component#readme","_id":"gatsby-remark-component@1.1.1","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"hebilicious","email":"xsh4k3@gmail.com"},"dist":{"integrity":"sha512-kbPHuvCyeyec3xwSukod09y/FflOxkfvQMS3mqPBDZP0IRWKXSYU509HHjIgmjJXiFKGc4vdlcwgvDSF6J7/NA==","shasum":"f44e71ae85a14f46121bceb46145be8133a7c548","tarball":"http://registry-npm.ywwl.com/gatsby-remark-component/download/gatsby-remark-component-1.1.1.tgz","fileCount":8,"unpackedSize":18186,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyjtrEjU6JNLejf3UmI7dshcLgMVXMMIMnY/P1xjVR1gIgFu4nykKwb1LXSwpIwubxLP3AkUZbTCTYGk3cTA2WGUI="}],"size":4612,"noattachment":false,"key":"/gatsby-remark-component/-/gatsby-remark-component-1.1.1.tgz"},"maintainers":[{"name":"hebilicious","email":"xsh4k3@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-remark-component_1.1.1_1518551917074_0.04121706506657663"},"_hasShrinkwrap":false,"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":1518551917801,"_cnpm_publish_time":1518551917801,"dist-tags":{"latest":"1.1.3"}}