{"_id":"@ehp/gatsby-source-filesystem","_rev":"2-e1efddb9ae70deaa6d792167fc6ad771","name":"@ehp/gatsby-source-filesystem","dist-tags":{"latest":"2.0.3"},"versions":{"2.0.2":{"name":"@ehp/gatsby-source-filesystem","description":"Gatsby plugin which parses files within a directory for further parsing by other plugins","version":"2.0.2","author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"devDependencies":{"@babel/cli":"7.0.0-beta.51","@babel/core":"7.0.0-beta.51","@babel/node":"7.0.0-beta.51","@babel/plugin-proposal-class-properties":"7.0.0-beta.51","@babel/plugin-proposal-optional-chaining":"7.0.0-beta.51","@babel/plugin-transform-runtime":"7.0.0-beta.51","@babel/preset-env":"7.0.0-beta.51","@babel/preset-flow":"7.0.0-beta.51","@babel/preset-react":"7.0.0-beta.51","@babel/runtime":"7.0.0-beta.51","babel-core":"7.0.0-bridge.0","babel-eslint":"8.2.1","babel-jest":"^22.4.3","chokidar":"^1.7.0","cross-env":"^5.1.4","eslint":"^4.19.1","eslint-config-google":"^0.9.1","eslint-config-prettier":"^2.9.0","eslint-plugin-flow-vars":"^0.5.0","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-import":"^2.9.0","eslint-plugin-jsx-a11y":"^6.0.2","eslint-plugin-prettier":"^2.6.0","eslint-plugin-react":"^7.7.0","flow-bin":"^0.42.0","glob":"^7.1.1","jest":"^22.4.3","jest-cli":"^22.4.3","lerna":"^3.0.0-beta.21","npm-run-all":"4.1.2","plop":"^1.8.1","prettier":"^1.12","prettier-eslint-cli":"4.7.1","remotedev-server":"^0.2.3","rimraf":"^2.6.1","yargs":"^10.0.3"},"dependencies":{"@babel/preset-env":"^7.0.0-beta.52","@babel/preset-react":"^7.0.0-beta.52","@babel/runtime":"7.0.0-beta.51","better-queue":"^3.8.7","bluebird":"^3.5.0","chokidar":"^1.7.0","fs-extra":"^5.0.0","got":"^7.1.0","md5-file":"^3.1.1","mime":"^2.2.0","pretty-bytes":"^4.0.2","slash":"^1.0.0","valid-url":"^1.0.9","xstate":"^3.1.0"},"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem#readme","keywords":["gatsby","gatsby-plugin"],"license":"MIT","peerDependencies":{"gatsby":">2.0.0-alpha"},"repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem"},"scripts":{"build":"babel src --out-dir . --ignore **/__tests__","prepare":"cross-env NODE_ENV=production npm run build","watch":"babel -w src --out-dir . --ignore **/__tests__"},"gitHead":"b889206ceaa7f93f66641c06a5a1c8bfdfc8de96","_id":"@ehp/gatsby-source-filesystem@2.0.2","_npmVersion":"6.1.0","_nodeVersion":"10.1.0","_npmUser":{"name":"eugenehp","email":"eugene.hp2012@gmail.com"},"dist":{"integrity":"sha512-PmsOdQSNLMs1qSWSbRus379rIoJOjUxC4ltcZ6BulVx1RJpiFZbIL2iL2pKhJGFlFV+FaJ8BylU8fldZnh2B8g==","shasum":"645ba50746f1d3a62db7388ad74fb5a9e67a0c5a","tarball":"https://registry.npmjs.org/@ehp/gatsby-source-filesystem/-/gatsby-source-filesystem-2.0.2.tgz","fileCount":11,"unpackedSize":30879,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbRSCACRA9TVsSAnZWagAAAaEP/2Wxi/QyiGbUtoYPm18y\nOkZIMdyWudjw4nmW9VW+V2U+aZAbS+zvjG25Ekcv0lC7bSouuunvZS275iCz\nQYA3VWiOGH4jLJKRhfkTJmZiPOLwPHx0YsMP7yuWwE7sR58aRiRdrw6IGPZY\nv40vtAlF7ERSvPiP11E9Y/Rd2+xE1ILBNmghx1AszuWfnaqwWSv7P6E/udf6\nBeN9FHMgTvuOUFE3rzN/ZVCKKtSzaa7ZHg6yLfKsh9mUnV07BINc2UUmvPhr\nwcp24g6J0qSmipIG2nNt5olOeG9ciwGCcCvdFHqhbsecuodtrAk1/WLahIBT\nshK1iZPW9MKNy1ptkUh0jvuF3676BuliTkulaSh/I27h39v+OfcMzocbhuD8\nI2KOlSbQ6JjgYiJ+uh0Qsgw4JR3Fg/oGRWeMmWKKTQyXL2XzDBhzmXcqvWOp\ng5Ow3aJaRnw2M1jNYTEcewLScD+b3HMstwfBf3gkRcE5s4dQE2+mTQp81pn5\nkTdkuixXCLybHY0CAOVjA/rNLEkEF1bd8yI/d8X2vA363DeVRUsS/k1i7fAw\nKa5Ir8uqVYn4+L+/onSAiEFzBuj6I5drgWLouEzMVrqYbmdT/vld1UhdDQf2\nbqVa1XX3eHaCp9NtOdI4sI/VJv2I6brSxM2x0bk8ah/RwueBpBJXPhn9f0L3\nLBDT\r\n=6kKc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFglUtFiz/UkR7vQ03rUkmMf2bTopn1aShR+oWOv4++wIhAJjZGnJOutEp4HdxGWVM+cXZ+4ZBaA4UQwMw/9S8ZWPg"}]},"maintainers":[{"name":"eugenehp","email":"eugene.hp2012@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-source-filesystem_2.0.2_1531256960099_0.7062775015114175"},"_hasShrinkwrap":false},"2.0.3":{"name":"@ehp/gatsby-source-filesystem","description":"Gatsby plugin which parses files within a directory for further parsing by other plugins","version":"2.0.3","author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"devDependencies":{"@babel/cli":"7.0.0-beta.51","@babel/core":"7.0.0-beta.51","@babel/node":"7.0.0-beta.51","@babel/plugin-proposal-class-properties":"7.0.0-beta.51","@babel/plugin-proposal-optional-chaining":"7.0.0-beta.51","@babel/plugin-transform-runtime":"7.0.0-beta.51","@babel/preset-env":"7.0.0-beta.51","@babel/preset-flow":"7.0.0-beta.51","@babel/preset-react":"7.0.0-beta.51","@babel/runtime":"7.0.0-beta.51","babel-core":"7.0.0-bridge.0","babel-eslint":"8.2.1","babel-jest":"^22.4.3","chokidar":"^1.7.0","cross-env":"^5.1.4","eslint":"^4.19.1","eslint-config-google":"^0.9.1","eslint-config-prettier":"^2.9.0","eslint-plugin-flow-vars":"^0.5.0","eslint-plugin-flowtype":"^2.46.1","eslint-plugin-import":"^2.9.0","eslint-plugin-jsx-a11y":"^6.0.2","eslint-plugin-prettier":"^2.6.0","eslint-plugin-react":"^7.7.0","flow-bin":"^0.42.0","glob":"^7.1.1","jest":"^22.4.3","jest-cli":"^22.4.3","lerna":"^3.0.0-beta.21","npm-run-all":"4.1.2","plop":"^1.8.1","prettier":"^1.12","prettier-eslint-cli":"4.7.1","remotedev-server":"^0.2.3","rimraf":"^2.6.1","yargs":"^10.0.3"},"dependencies":{"@babel/preset-env":"^7.0.0-beta.52","@babel/preset-react":"^7.0.0-beta.52","@babel/runtime":"7.0.0-beta.51","better-queue":"^3.8.7","bluebird":"^3.5.0","chokidar":"^1.7.0","fs-extra":"^5.0.0","got":"^7.1.0","md5-file":"^3.1.1","mime":"^2.2.0","pretty-bytes":"^4.0.2","slash":"^1.0.0","valid-url":"^1.0.9","xstate":"^3.1.0"},"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem#readme","keywords":["gatsby","gatsby-plugin"],"license":"MIT","peerDependencies":{"gatsby":"1.9.273"},"repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem"},"scripts":{"build":"babel src --out-dir . --ignore **/__tests__","prepare":"cross-env NODE_ENV=production npm run build","watch":"babel -w src --out-dir . --ignore **/__tests__"},"gitHead":"3f658f0d01f44d78f97da2b8ee77aa13a6d90bc2","_id":"@ehp/gatsby-source-filesystem@2.0.3","_npmVersion":"6.1.0","_nodeVersion":"10.1.0","_npmUser":{"name":"eugenehp","email":"eugene.hp2012@gmail.com"},"dist":{"integrity":"sha512-7Ab1LKNivgUOktuqNn8SIa5iq7rAjTRHMmh4x8HO6bgKCR+XqeMQrbDYWkx8XHtxxjiXgEvkUvFgAFarabmWSw==","shasum":"33c7fe2f485c8faa2069dec69a1449ba7b71ca37","tarball":"https://registry.npmjs.org/@ehp/gatsby-source-filesystem/-/gatsby-source-filesystem-2.0.3.tgz","fileCount":11,"unpackedSize":30874,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbRS4UCRA9TVsSAnZWagAAjoYP+we22n5ogLioo+htvTiE\n/YP/7eZd6kYNEd/UOKfU5vS9XP83ZozdSNvBAvL/HO288PqWQ3M2yDFnByPo\nNABXBNFXG5osznLhrGCr/trqUtvM6JiTDms/C5QQ1lC4Ux4zuGYxr3svVbFt\nvP6OgaPesB5fT3jUFm2DQjCRctJAkFLKp6md3bEA+zyrrUy79qij+BcyhoIq\nLcIbCU+cNWDm0nbTPPFU0P2umBH1A5FKV7NGI6qxOG0mzoMmG+UtjybWk5Zy\nVLNVk4MNlfUbkVuk7j5W4ORSHLXADo+xGVENW5pxo4wPe/wHWNCkJoeQZNpE\nmW8B4qHwbU77PXZeAb1+3QlcUtkpcv88s2OSx4clsj8CHPm7Fp+qQ1xM45Vx\ngcjJ+otCWS1XGjtr+KDYm5SwB33sAoVujmSV4RTOE6mE8GCGEikxhikA25w1\nbMeaDeZOslKOQ2skcqt8fpUXr0qPAl2OYNAbzsa6FJaHPcW9q5tF9pTr5/2b\n1qJoi1RKnNS0Mgh4YlBuAKfggFl+8J1Rigef/9g2ocEnkIcY9/j2GX87L7TT\ne8N+9qGcROReIct6qFkPoWt9P6bjMLHvr/EYvFjdvYJ377jjx58lwZ1SDMp4\nJQA0yoXYdt74MDHKYLlyTBP8ClfzrZYd8VNZiCRPdrrZtOcQ4zyhWaYmjDwA\nHJXj\r\n=uDbi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFnEAOxkHMANNIgtCbFxCxjTGqdd5MB2pMC4mO6zDWfpAiB+borGX75DN0d6ZAyj3auPSI7wXwBqpRTo1T3R2FGAtQ=="}]},"maintainers":[{"name":"eugenehp","email":"eugene.hp2012@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-source-filesystem_2.0.3_1531260436463_0.8712190636690857"},"_hasShrinkwrap":false}},"time":{"created":"2018-07-10T21:09:19.964Z","2.0.2":"2018-07-10T21:09:20.186Z","modified":"2022-04-05T06:58:28.548Z","2.0.3":"2018-07-10T22:07:16.558Z"},"maintainers":[{"name":"eugenehp","email":"eugene.hp2012@gmail.com"}],"description":"Gatsby plugin which parses files within a directory for further parsing by other plugins","homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem#readme","keywords":["gatsby","gatsby-plugin"],"repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem"},"author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"license":"MIT","readme":"# gatsby-source-filesystem\n\nPlugin for creating `File` nodes from the file system. The various \"transformer\"\nplugins transform `File` nodes into various other types of data e.g.\n`gatsby-transformer-json` transforms JSON files into JSON data nodes and\n`gatsby-transformer-remark` transforms markdown files into `MarkdownRemark`\nnodes from which you can query an HTML representation of the markdown.\n\n## Install\n\n`npm install --save gatsby-source-filesystem`\n\n## How to use\n\n```javascript\n// In your gatsby-config.js\nmodule.exports = {\n  plugins: [\n    // You can have multiple instances of this plugin\n    // to read source nodes from different locations on your\n    // filesystem.\n    //\n    // The following sets up the Jekyll pattern of having a\n    // \"pages\" directory for Markdown files and a \"data\" directory\n    // for `.json`, `.yaml`, `.csv`.\n    {\n      resolve: `gatsby-source-filesystem`,\n      options: {\n        name: `pages`,\n        path: `${__dirname}/src/pages/`,\n      },\n    },\n    {\n      resolve: `gatsby-source-filesystem`,\n      options: {\n        name: `data`,\n        path: `${__dirname}/src/data/`,\n      },\n    },\n  ],\n}\n```\n\n## How to query\n\nYou can query file nodes like the following:\n\n```graphql\n{\n  allFile {\n    edges {\n      node {\n        extension\n        dir\n        modifiedTime\n      }\n    }\n  }\n}\n```\n\n## Helper functions\n\n`gatsby-source-filesystem` exports two helper functions:\n\n- `createFilePath`\n- `createRemoteFileNode`\n\n### createFilePath\n\nWhen building pages from files, you often want to create a URL from a file's path on the file system. E.g. if you have a markdown file at `src/content/2018-01-23-an-exploration-of-the-nature-of-reality/index.md`, you might want to turn that into a page on your site at `example.com/2018-01-23-an-exploration-of-the-nature-of-reality/`. `createFilePath` is a helper function to make this task easier.\n\n```javascript\ncreateFilePath({\n  // The node you'd like to convert to a path\n  // e.g. from a markdown, JSON, YAML file, etc\n  node:\n  // Method used to get a node\n  // The parameter from `onCreateNode` should be passed in here\n  getNode:\n  // The base path for your files.\n  // Defaults to `src/pages`. For the example above, you'd use `src/contents`.\n  basePath:\n  // Whether you want your file paths to contain a trailing `/` slash\n  // Defaults to true\n  trailingSlash:\n})\n```\n\n#### Example usage\n\nThe following is taken from [Gatsby Tutorial, Part Seven](https://www.gatsbyjs.org/tutorial/part-seven/) and is used to create URL slugs for markdown pages.\n\n```javascript\nconst { createFilePath } = require(`gatsby-source-filesystem`)\n\nexports.onCreateNode = ({ node, getNode, boundActionCreators }) => {\n  const { createNodeField } = boundActionCreators\n  // Ensures we are processing only markdown files\n  if (node.internal.type === \"MarkdownRemark\") {\n    // Use `createFilePath` to turn markdown files in our `data/faqs` directory into `/faqs/slug`\n    const relativeFilePath = createFilePath({\n      node,\n      getNode,\n      basePath: \"data/faqs/\",\n    })\n\n    // Creates new query'able field with name of 'slug'\n    createNodeField({\n      node,\n      name: \"slug\",\n      value: `/faqs${relativeFilePath}`,\n    })\n  }\n}\n```\n\n### createRemoteFileNode\n\nWhen building source plugins for remote data sources such as headless CMSs, their data will often link to files stored remotely that are often convenient to download so you can work with them locally.\n\nThe `createRemoteFileNode` helper makes it easy to download remote files and add them to your site's GraphQL schema.\n\n```javascript\ncreateRemoteFileNode({\n  // The source url of the remote file\n  url: `https://example.com/a-file.jpg`,\n\n  // The redux store which is passed to all Node APIs.\n  store,\n\n  // Gatsby's cache which the helper uses to check if the file has been downloaded already. It's passed to all Node APIs.\n  cache,\n\n  // The boundActionCreator used to create nodes\n  createNode,\n\n  // OPTIONAL\n  // Adds htaccess authentication to the download request if passed in.\n  auth: { htaccess_user: `USER`, htaccess_pass: `PASSWORD` },\n})\n```\n\n#### Example usage\n\nThe following example is pulled from [gatsby-source-wordpress](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-wordpress). Downloaded files are created as `File` nodes and then linked to the WordPress Media node, so it can be queried both as a regular `File` node and from the `localFile` field in the Media node.\n\n```javascript\nconst { createRemoteFileNode } = require(`gatsby-source-filesystem`)\n\nexports.downloadMediaFiles = ({ nodes, store, cache, createNode, _auth }) => {\n  nodes.map(async node => {\n    let fileNode\n    // Ensures we are only processing Media Files\n    // `wordpress__wp_media` is the media file type name for Wordpress\n    if (node.__type === `wordpress__wp_media`) {\n      try {\n        fileNode = await createRemoteFileNode({\n          url: node.source_url,\n          store,\n          cache,\n          createNode,\n          auth: _auth,\n        })\n      } catch (e) {\n        // Ignore\n      }\n    }\n\n    // Adds a field `localFile` to the node\n    // ___NODE appendix tells Gatsby that this field will link to another node\n    if (fileNode) {\n      node.localFile___NODE = fileNode.id\n    }\n  })\n}\n```\n\nThe file node can then be queried using GraphQL. See an example of this in the [gatsby-source-wordpress README](/packages/gatsby-source-wordpress/#image-processing) where downloaded images are queried using [gatsby-transformer-sharp](/packages/gatsby-transformer-sharp/) to use in the component [gatsby-image](/packages/gatsby-image/).\n","readmeFilename":"README.md"}