5.0.0 • Published 1 year ago

gatsby-yaml-full-import v5.0.0

Weekly downloads
56
License
MIT
Repository
github
Last release
1 year ago

gatsby-yaml-full-import npm

Plugin for gatsby-transformer-yaml-full to enable import of other YAML files or fields using !import tag.

Installation

npm install gatsby-yaml-full-import gatsby-transformer-yaml-full

Usage

/* gatsby-config.js */

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-transformer-yaml-full',
      options: {
        plugins: ['gatsby-yaml-full-import']
      }
    }
  ]
}

Import all fields from a file

The following ./index.yaml and ./post.yaml files, respectively:

---
importedPost: !import ./post.yaml
title: Post title

Will return:

{
  data: {
    indexYaml: {
      importedPost: {
        title: 'Post title'
      }
    }
  }
}

With the following query:

query {
  indexYaml {
    importedPost {
      title
    }
  }
}

Import a specific field from a file

An exclamation mark (!) separates the file name from the field query. The field query supports array indexes too.

The following ./index.yaml and ./post.yaml files, respectively:

---
importedAuthorName: !import ./post.yaml!authors.1.name
authors:
- name: John Doe
- name: John Q.

Will return:

{
  data: {
    indexYaml: {
      importedAuthorName: 'John Q.'
    }
  }
}

With the following query:

query {
  indexYaml {
    importedAuthorName
  }
}

License

The MIT License

5.0.0

1 year ago

4.0.5

2 years ago

4.0.4

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago