3.13.1 • Published 3 months ago

gatsby-page-utils v3.13.1

Weekly downloads
450,295
License
MIT
Repository
github
Last release
3 months ago

gatsby-page-utils

Usage

npm install gatsby-page-utils

Example

const {
  createPath,
  ignorePath,
  validatePath,
  watchDirectory,
} = require(`gatsby-page-utils`)

// ...

const pagesDirectory = "/pages"
watchDirectory(
  pagesDirectory,
  "**/*.{js, jsx}",
  addedPath => {
    // Filter out special components that shouldn't be made into
    // pages.
    if (!validatePath(addedPath)) {
      return
    }

    // Filter out anything matching the given ignore patterns and options
    if (ignorePath(addedPath, "*/connexion")) {
      return
    }

    // Create page object
    const createdPath = createPath(addedPath)
    const page = {
      path: createdPath,
      component: systemPath.join(pagesDirectory, addedPath),
    }

    // Add page
    createPage(page)
  },
  removedPath => {
    // Delete the page for the now deleted component.
    const componentPath = systemPath.join(pagesDirectory, removedPath)
    store.getState().pages.forEach(page => {
      if (page.component === componentPath) {
        deletePage({
          path: createPath(removedPath),
          component: componentPath,
        })
      }
    })
  }
)

watchDirectory

Watch activity on a directory and call functions each time a file is added or removed

propertydescriptiontype
pathDirectory path in which pages are storedString
globA glob that select files to watchString
onNewFileA function called each time a new file is addedFunction
onRemovedFileA function called each time a file is removedFunction

createPath

Create a page path from a file path. It returns the page path.

propertydescriptiontype
pathFile pathString

validatePath

Validate 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.

propertydescriptiontype
pathFile pathString

ignorePath

Determines 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.

propertydescriptiontype
pathFile pathString
ignoreA pattern to match with file path(Object | String | Array)
3.14.0-next.2

3 months ago

3.13.1

3 months ago

3.14.0-next.1

4 months ago

3.13.0

4 months ago

3.14.0-next.0

4 months ago

3.12.1

6 months ago

3.13.0-next.1

5 months ago

3.12.0

8 months ago

3.13.0-next.0

9 months ago

3.10.0

12 months ago

3.11.0-next.1

11 months ago

3.11.0-next.0

12 months ago

3.11.0

11 months ago

3.12.0-next.0

11 months ago

3.12.0-next.1

10 months ago

3.10.0-next.1

12 months ago

3.10.0-next.0

1 year ago

3.10.0-next.2

12 months ago

3.9.0

1 year ago

3.8.0-next.0

1 year ago

3.8.0

1 year ago

3.7.0

1 year ago

3.9.0-next.0

1 year ago

3.9.0-next.1

1 year ago

3.5.0-next.1

1 year ago

3.7.0-next.0

1 year ago

3.6.0-next.0

1 year ago

3.6.0

1 year ago

3.5.0

1 year ago

3.4.0

1 year ago

3.1.0-next.0

1 year ago

3.2.0

1 year ago

3.4.0-next.2

1 year ago

3.4.0-next.1

1 year ago

3.4.0-next.0

1 year ago

3.1.0

1 year ago

3.0.0-next.2

2 years ago

3.0.0-next.1

2 years ago

3.0.0-next.3

2 years ago

3.0.0-next.0

2 years ago

3.0.0

1 year ago

3.5.0-next.0

1 year ago

3.2.0-next.0

1 year ago

1.15.0

1 year ago

3.3.0-next.0

1 year ago

3.3.0-next.1

1 year ago

2.25.0

1 year ago

2.24.1

2 years ago

3.3.1

1 year ago

3.3.0

1 year ago

2.22.0

2 years ago

2.24.0-next.1

2 years ago

2.24.0-next.0

2 years ago

2.23.0-next.0

2 years ago

2.24.0

2 years ago

2.25.0-next.0

2 years ago

2.23.0

2 years ago

2.21.0-next.1

2 years ago

2.21.0-next.2

2 years ago

2.21.0-next.0

2 years ago

2.19.0

2 years ago

2.18.1

2 years ago

2.18.0

2 years ago

2.21.0

2 years ago

2.18.0-next.0

2 years ago

2.18.0-next.1

2 years ago

2.19.0-next.1

2 years ago

2.19.0-next.0

2 years ago

2.16.0-next.0

2 years ago

2.17.0

2 years ago

2.20.0

2 years ago

2.16.0

2 years ago

2.15.0

2 years ago

2.17.0-next.0

2 years ago

2.17.0-next.1

2 years ago

2.22.0-next.0

2 years ago

2.14.1

2 years ago

2.20.0-next.0

2 years ago

2.15.0-next.0

2 years ago

2.15.0-next.1

2 years ago

2.14.0-next.1

2 years ago

2.14.0-next.2

2 years ago

2.14.0-next.0

2 years ago

2.14.0-next.3

2 years ago

2.14.0

2 years ago

2.13.0

2 years ago

2.11.0

2 years ago

2.11.1

2 years ago

2.12.0-next.2

2 years ago

2.12.0-next.1

2 years ago

2.12.0-next.3

2 years ago

2.12.0-next.0

2 years ago

2.10.1

2 years ago

2.10.0

2 years ago

2.11.0-next.0

2 years ago

2.11.0-next.1

2 years ago

2.10.0-next.3

2 years ago

2.9.1

2 years ago

2.13.0-next.0

2 years ago

2.12.0

2 years ago

2.12.1

2 years ago

2.9.0

2 years ago

2.9.0-next.1

2 years ago

2.8.1

2 years ago

2.10.0-next.0

2 years ago

2.10.0-next.1

2 years ago

2.10.0-next.2

2 years ago

2.8.2

2 years ago

2.4.0

2 years ago

2.6.0-next.2

2 years ago

2.6.0-next.0

2 years ago

2.6.0-next.1

2 years ago

2.3.0

2 years ago

2.7.0-next.0

2 years ago

2.7.0-next.1

2 years ago

2.7.0-next.2

2 years ago

2.7.0-next.3

2 years ago

2.9.0-next.0

2 years ago

2.8.0

2 years ago

2.4.0-next.1

2 years ago

2.4.0-next.0

2 years ago

2.7.0

2 years ago

2.5.0-next.0

2 years ago

2.5.0-next.3

2 years ago

2.5.0-next.2

2 years ago

2.5.0-next.1

2 years ago

2.6.0

2 years ago

2.8.0-next.1

2 years ago

2.8.0-next.0

2 years ago

2.5.0

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.2.0

2 years ago

2.2.0-next.2

2 years ago

2.2.0-next.1

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.3

2 years ago

2.3.0-next.1

2 years ago

2.3.0-next.0

2 years ago

2.2.0-next.0

2 years ago

2.1.0

2 years ago

2.0.0

3 years ago

2.1.0-next.0

3 years ago

2.0.0-zz-next.3

3 years ago

2.0.0-zz-next.2

3 years ago

1.14.0

3 years ago

2.0.0-zz-next.0

3 years ago

2.0.0-zz-next.1

3 years ago

2.0.0-next.2

3 years ago

2.0.0-next.0

3 years ago

2.0.0-next.1

3 years ago

1.14.0-next.2

3 years ago

1.14.0-next.1

3 years ago

1.13.0

3 years ago

1.13.0-next.2

3 years ago

1.14.0-next.0

3 years ago

1.13.0-next.1

3 years ago

1.12.0

3 years ago

1.13.0-next.0

3 years ago

1.12.0-next.3

3 years ago

1.12.0-next.1

3 years ago

1.12.0-next.2

3 years ago

1.11.0

3 years ago

1.12.0-next.0

3 years ago

1.10.0

3 years ago

1.11.0-next.0

3 years ago

1.10.0-next.1

3 years ago

1.9.0

3 years ago

1.10.0-next.0

3 years ago

1.8.0

3 years ago

1.9.0-next.0

3 years ago

1.6.0

3 years ago

1.7.0-next.1

3 years ago

1.7.0-next.2

3 years ago

1.8.0-next.0

3 years ago

1.8.0-next.1

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.4.0-next.3

3 years ago

1.6.0-next.0

3 years ago

1.7.0-next.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.5.0-next.0

3 years ago

1.4.0-next.1

3 years ago

1.3.0

3 years ago

1.4.0-next.0

3 years ago

1.3.0-next.1

3 years ago

1.2.0

3 years ago

1.3.0-next.0

3 years ago

1.1.0

3 years ago

1.2.0-next.0

3 years ago

1.1.0-next.2

3 years ago

1.0.0

3 years ago

1.0.0-v3rc.0

3 years ago

1.1.0-next.1

3 years ago

1.1.0-next.0

3 years ago

1.0.0-next.2

3 years ago

0.9.1

3 years ago

1.0.0-next.1

3 years ago

1.0.0-next.0

3 years ago

0.9.0

3 years ago

0.10.0-next.0

3 years ago

0.8.0

3 years ago

0.9.0-next.0

3 years ago

0.7.0

3 years ago

0.8.0-next.0

3 years ago

0.7.0-next.1

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.7.0-next.0

3 years ago

0.6.0-next.1

3 years ago

0.5.0

3 years ago

0.6.0-next.0

3 years ago

0.4.0

3 years ago

0.5.0-next.0

3 years ago

0.3.0

3 years ago

0.4.0-next.0

3 years ago

0.3.0-next.1

3 years ago

0.2.30

3 years ago

0.3.0-next.0

3 years ago

0.2.29

4 years ago

0.2.28

4 years ago

0.2.27

4 years ago

0.2.26

4 years ago

0.2.25

4 years ago

0.2.24

4 years ago

0.2.23

4 years ago

0.2.22

4 years ago

0.2.21

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.45

4 years ago

0.0.44

4 years ago

0.0.43

4 years ago

0.0.42

4 years ago

0.0.40

4 years ago

0.0.41

4 years ago

0.0.39

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.29

4 years ago

0.0.28

4 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago