Skip to main content
Community Plugin
View plugin on GitHub
See starters using this

gatsby-yaml-full-import

Plugin for gatsby-transformer-yaml-full to enable YAML files importing using !import tag.

Install

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

Configure

// gatsby-config.js

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

Usage

Use the !import tag to import the content of a YAML file inside a property.

Importing YAML data from another file

YAML files

# post.yaml

title: Post title
# index.yaml

importedPost: !import ./post.yaml

Returning object

{
  importedPost: {
    title: 'Post title'
  }
}

Importing a specific field

YAML files

# post.yaml

authors:
- name: John Doe
- name: John Q.
# index.yaml

importedAuthorName: !import ./post.yaml authors.0.name

Returning object

{
  importedAuthorName: 'John Doe'
}