{"name":"gatsby-page-utils","version":"3.16.0","keywords":["gatsby"],"author":{"name":"Yvonnick FRIN","email":"frin.yvonnick@gmail.com"},"license":"MIT","_id":"gatsby-page-utils@3.16.0","maintainers":[{"name":"pieh","email":"misiek.piechowiak@gmail.com"},{"name":"kathmbeck","email":"katherine.beck@netlify.com"},{"name":"serhalp-netlify","email":"philippe.serhal@netlify.com"},{"name":"mlgualtieri-gatsby","email":"mike.gualtieri@netlify.com"},{"name":"wardpeet","email":"ward@coding-tech.com"}],"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-page-utils#readme","bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"dist":{"shasum":"ab11035b8b7c7b35d74b8a9c4b10772b14d69c58","tarball":"http://registry-npm.ywwl.com/gatsby-page-utils/download/gatsby-page-utils-3.16.0.tgz","fileCount":20,"integrity":"sha512-dZvHyhb9XvqeRlU0dzeeGHhgKVjMfStzWsPCQzSIf3A98U2LbBvAClJZhdFhLoNcYtLTo5hq8518G2+DlNVe6w==","signatures":[{"sig":"MEUCIHOGxk+uGUhJjIObO1CXT8WTYhFEDfKvs3t+9FDU2aBmAiEA1UOGd+i6t3jQWGBt8nUd7agU6e7wk4doYvzampiLVcM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":58440,"size":11532,"noattachment":false,"key":"/gatsby-page-utils/-/gatsby-page-utils-3.16.0.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0 <26"},"exports":{".":"./dist/index.js","./*":"./dist/*.js"},"gitHead":"92d6c67dcf10b641adf5fcc81ebeec5f50b75e40","scripts":{"build":"babel src --out-dir dist/ --ignore \"**/__tests__\" --extensions \".ts\"","watch":"babel -w src --out-dir dist/ --ignore \"**/__tests__\" --extensions \".ts\"","prepare":"cross-env NODE_ENV=production npm run build && npm run typegen","typegen":"rimraf --glob \"dist/**/*.d.ts\" && tsc --emitDeclarationOnly --declaration --declarationDir dist/"},"_npmUser":{"name":"serhalp-netlify","email":"philippe.serhal@netlify.com"},"repository":{"url":"git+https://github.com/gatsbyjs/gatsby.git","type":"git","directory":"packages/gatsby-page-utils"},"_npmVersion":"lerna/3.22.1/node@v22.19.0+arm64 (darwin)","description":"Gatsby library that helps creating pages","directories":{},"_nodeVersion":"22.19.0","dependencies":{"glob":"^7.2.3","lodash":"^4.17.21","bluebird":"^3.7.2","chokidar":"^3.6.0","micromatch":"^4.0.5","@babel/runtime":"^7.20.13","fs-exists-cached":"^1.0.0","gatsby-core-utils":"^4.16.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^5.0.5","cross-env":"^7.0.3","@babel/cli":"^7.20.7","typescript":"^5.1.6","@babel/core":"^7.20.12","@types/micromatch":"^4.0.6","babel-preset-gatsby-package":"^3.16.0"},"_npmOperationalInternal":{"tmp":"tmp/gatsby-page-utils_3.16.0_1769459242717_0.5838133975203688","host":"s3://npm-registry-packages-npm-production"},"readme":"# gatsby-page-utils\n\n## Usage\n\n```shell\nnpm install gatsby-page-utils\n```\n\n### Example\n\n```js\nconst {\n  createPath,\n  ignorePath,\n  validatePath,\n  watchDirectory,\n} = require(`gatsby-page-utils`)\n\n// ...\n\nconst pagesDirectory = \"/pages\"\nwatchDirectory(\n  pagesDirectory,\n  \"**/*.{js, jsx}\",\n  addedPath => {\n    // Filter out special components that shouldn't be made into\n    // pages.\n    if (!validatePath(addedPath)) {\n      return\n    }\n\n    // Filter out anything matching the given ignore patterns and options\n    if (ignorePath(addedPath, \"*/connexion\")) {\n      return\n    }\n\n    // Create page object\n    const createdPath = createPath(addedPath)\n    const page = {\n      path: createdPath,\n      component: systemPath.join(pagesDirectory, addedPath),\n    }\n\n    // Add page\n    createPage(page)\n  },\n  removedPath => {\n    // Delete the page for the now deleted component.\n    const componentPath = systemPath.join(pagesDirectory, removedPath)\n    store.getState().pages.forEach(page => {\n      if (page.component === componentPath) {\n        deletePage({\n          path: createPath(removedPath),\n          component: componentPath,\n        })\n      }\n    })\n  }\n)\n```\n\n#### watchDirectory\n\nWatch activity on a directory and call functions each time a file is added or removed\n\n| property      | description                                     | type     |\n| ------------- | ----------------------------------------------- | -------- |\n| path          | Directory path in which pages are stored        | String   |\n| glob          | A glob that select files to watch               | String   |\n| onNewFile     | A function called each time a new file is added | Function |\n| onRemovedFile | A function called each time a file is removed   | Function |\n\n#### createPath\n\nCreate a page path from a file path. It returns the page path.\n\n| property | description | type   |\n| -------- | ----------- | ------ |\n| path     | File path   | String |\n\n#### validatePath\n\nValidate a file path. It verifies that the path doesn't contain specific characters or strings. It returns `true` if the path is valid otherwise it returns `false`.\n\n| property | description | type   |\n| -------- | ----------- | ------ |\n| path     | File path   | String |\n\n#### ignorePath\n\nDetermines if path should be ignored regarding of a ignore pattern passed as parameter. It returns `true` if the passed path should be ignored otherwise it returns `false`.\n\n| property | description                       | type                        |\n| -------- | --------------------------------- | --------------------------- |\n| path     | File path                         | String                      |\n| ignore   | A pattern to match with file path | (Object \\| String \\| Array) |\n","publish_time":1769459242926,"_cnpm_publish_time":1769459242926,"dist-tags":{"alpha-9689ff":"2.23.0-alpha-9689ff.25","alpha-adapters":"3.10.0-alpha-adapters.165","alpha-mdx-v2":"2.18.0-alpha-mdx-v2.68","alpha-qe-sm":"1.14.0-alpha-qe-sm.46","alpha-remote-fetch":"1.14.0-alpha-remote-fetch.79","alpha-remote-file":"1.10.0-alpha-remote-file.48","alpha-trailing-slash":"2.5.0-alpha-trailing-slash.76","alpha-transformer-json":"2.14.0-alpha-transformer-json.26","alpha-ts-jit":"2.6.0-alpha-ts-jit.27","alpha-v5":"3.0.0-alpha-v5.d20221012t101120.57","berry-mdx":"0.0.38-berry-mdx.56","coreutils":"1.12.0-coreutils.29","drupal-next":"1.14.0-drupal-next.94","drupal-proxyurl":"3.0.0-alpha-drupal-proxyurl.14","drupal-self-reference":"2.18.0-alpha-drupal-self-reference.18","functions-next":"1.4.0-functions-next.18","image-cdn":"2.9.0-alpha-image-service2.14","image-service":"2.8.0-alpha-image-service.35","incbuild-collections":"0.2.21-incbuild-collections.159","latest":"3.16.0","latest-v3":"1.15.0","latest-v4":"2.25.0","mdxv4-rc":"2.20.0-mdxv4-rc.124","next":"3.17.0-next.0","otp-test":"0.0.13-otp-test.31","preview-gh-api":"2.23.0-alpha-preview-gh-api.26","prompt-restart":"0.1.2-prompt-restart.146","telemetry-test":"0.4.0-telemetry-test.360","unifiedroutes":"0.1.3-unifiedroutes.76","v3rc":"1.0.0-v3rc.0","wp-image-cdn-auth":"2.15.0-alpha-wp-image-cdn-auth.45"}}