gatsby-transformer-front10-story-loader

1.0.6 • Public • Published

gatsby-transformer-javascript-frontmatter

Parses Stories files to extract content.

Install

npm install --save-dev @front10/gatsby-plugin-front10-story-loader

How to use

To use this plugin you also need gatsby-source-filesystem installed and configured.

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `./.ui/stories/gatsby/`
      }
    },
    "@front10/gatsby-plugin-front10-story-loader"
  ]
};

Parsing algorithm

In a .story.js (or .story.jsx / .story.ts / .story.tsx) file, export a frontmatter object to set your metadata variables, like so:

export default {
  name: "Sorting",
  summary: "",
  hiddenInMobile: false,
  code: `<Icon icon="icon icon-switch"/>`
};

How to query

You'd be able to query your frontmatter like:

{
  allStories {
    edges {
      node {
        story {
          code
          hiddenInMobile
          name
          summary
        }
      }
    }
  }
}

Which would return something like:

{
  "data": {
    "stories": {
      "edges": [
        {
          "node": {
            "story": {
              "code": "<Icon icon=\"icon icon-switch\"/>",
              "hiddenInMobile": false,
              "name": "Sorting",
              "summary": ""
            }
          }
        }
      ]
    }
  }
}

Package Sidebar

Install

npm i gatsby-transformer-front10-story-loader

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

5.05 kB

Total Files

6

Last publish

Collaborators

  • ycgarrido