# @cs125/gatsby-source-filesystem-frontmatter

> Gatsby plugin which parses files within a directory for further parsing by other plugins, while also parsing YAML front matter from all files

Latest version **2.1.40-rc17** (published 2020-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cs125/gatsby-source-filesystem-frontmatter
pnpm add @cs125/gatsby-source-filesystem-frontmatter
yarn add @cs125/gatsby-source-filesystem-frontmatter
bun add @cs125/gatsby-source-filesystem-frontmatter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.40-rc17 |
| Published | 2020-09-26 |
| First published | 2019-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 16 |
| Unpacked size | 34.3 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 2 |
| Author | Kyle Mathews |
| Maintainers | geoffrey.challen |
| Keywords | gatsby, gatsby-plugin |

## Links

- npm: https://www.npmjs.com/package/@cs125/gatsby-source-filesystem-frontmatter
- Repository: https://github.com/cs125-illinois/gatsby-source-filesystem-frontmatter
- Issues: https://github.com/cs125-illinois/gatsby-source-filesystem-frontmatter/issues
- npm.io page: https://npm.io/package/@cs125/gatsby-source-filesystem-frontmatter

## Dependencies (16)

- [got](https://npm.io/package/got.md) ^10.2.2
- [mime](https://npm.io/package/mime.md) ^2.4.4
- [xstate](https://npm.io/package/xstate.md) ^4.7.6
- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2
- [chokidar](https://npm.io/package/chokidar.md) 3.3.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [md5-file](https://npm.io/package/md5-file.md) ^4.0.0
- [progress](https://npm.io/package/progress.md) ^2.0.3
- [copyfiles](https://npm.io/package/copyfiles.md) ^2.3.0
- [file-type](https://npm.io/package/file-type.md) ^13.1.2
- [valid-url](https://npm.io/package/valid-url.md) ^1.0.9
- [read-chunk](https://npm.io/package/read-chunk.md) ^3.2.0
- [gray-matter](https://npm.io/package/gray-matter.md) ^4.0.2
- [better-queue](https://npm.io/package/better-queue.md) ^3.8.10
- [pretty-bytes](https://npm.io/package/pretty-bytes.md) ^5.3.0
- [gatsby-core-utils](https://npm.io/package/gatsby-core-utils.md) ^1.0.26

## Recent versions

- 2.1.40-rc17 (latest) — 2020-09-26
- 2.1.40-rc16 — 2020-09-26
- 2.1.40-rc15 — 2020-09-26
- 2.1.40-rc14 — 2020-01-27
- 2.1.40-rc13 — 2020-01-27
- 2.1.40-rc12 — 2020-01-24
- 2.1.40-rc10 — 2020-01-24
- 2.1.40-rc9 — 2020-01-24
- 2.1.40-rc8 — 2020-01-24
- 2.1.40-rc7 — 2019-12-25
- 2.1.40-rc6 — 2019-12-25
- 2.1.40-rc5 — 2019-12-25
- 2.1.40-rc4 — 2019-12-25
- 2.1.40-rc3 — 2019-12-25
- 2.1.40-rc2 — 2019-12-25
- … 1 more at https://npm.io/package/@cs125/gatsby-source-filesystem-frontmatter/versions

## README

# @cs125/gatsby-source-filesystem-frontmatter

Adds support for reading frontmatter from any file to
[`gatsby-source-frontmatter`](https://www.gatsbyjs.org/packages/gatsby-source-filesystem/).

## Install

```bash
npm i @cs125/gatsby-source-filesystem-frontmatter
```

## Use

Review the documentation and examples from
[`gatsby-source-frontmatter`](https://www.gatsbyjs.org/packages/gatsby-source-filesystem/).

`gatsby-source-filesystem-frontmatter` adds a `frontMatter` option to
`gatsby-source-filesystem`.

```javascript
// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `@cs125/gatsby-source-filesystem-frontmatter`,
      options: {
        // options from gatsby-source-filesystem are supported
        name: `data`,
        path: `${__dirname}/src/data/`,
        ignore: [`**/\.*`], // ignore files starting with a dot
        frontMatter: true, // read frontmatter from files in this directory
      },
    },
  ],
}
```

## Options

If the `frontMatter` option is set to `true`,
`gatsby-source-filesystem-frontmatter` will attempt to read YAML front matter
from each file using [`gray-matter`](https://www.npmjs.com/package/gray-matter).

Given the following file:

```asciidoc
---
author: Geoffrey Challen
---

= Test

This is a test. This is only a test.
```

You can query attributes defined in its front matter like this:

```graphql
{
  allFile {
    edges {
      node {
        frontMatter {
          author
        }
      }
    }
  }
}
```

Or, if you are using a page query to get Asciidoc content, for example, your
query will look like this:

```js
export const pageQuery = graphql`
  query($id: String!) {
    asciidoc(id: { eq: $id }) {
      document {
        title
      }
      parent {
        ... on File {
          frontMatter {
            author
          }
        }
      }
      html
    }
  }
`
```

## Example

This repository contains a minimal example Gatsby site that uses
`@cs125/gatsby-source-filesystem-frontmatter` to extract frontmatter and
[`gatsby-transformer-asciidoc`](https://www.gatsbyjs.org/packages/gatsby-transformer-asciidoc/)
to transform Asciidoc files. Note that the extra `babel.config.json` file in the
root of the repository is needed to allow both the example Gatsby site and
plugin to share the same repository.

---
_Source: https://npm.io/package/@cs125/gatsby-source-filesystem-frontmatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
