# @undataforum/gatsby-theme-blog

> A Gatsby theme for a blog.

Latest version **0.12.0** (published 2020-08-03) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @undataforum/gatsby-theme-blog
pnpm add @undataforum/gatsby-theme-blog
yarn add @undataforum/gatsby-theme-blog
bun add @undataforum/gatsby-theme-blog
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2020-08-03 |
| First published | 2019-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 38.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Thilo Maier |
| Maintainers | 454de6e |
| Keywords | gatsby, gatsby-theme, gatsby-plugin, theme-ui, undataforum |

## Links

- npm: https://www.npmjs.com/package/@undataforum/gatsby-theme-blog
- Repository: https://github.com/undataforum/gatsby-themes
- Homepage: https://github.com/UNDataForum/gatsby-themes/tree/master/themes/gatsby-theme-blog
- Issues: https://github.com/undataforum/gatsby-themes/issues
- npm.io page: https://npm.io/package/@undataforum/gatsby-theme-blog

## Dependencies (9)

- [remark](https://npm.io/package/remark.md) ^12.0.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [react-intl](https://npm.io/package/react-intl.md) ^5.0.0
- [gatsby-image](https://npm.io/package/gatsby-image.md) ^2.4.14
- [strip-markdown](https://npm.io/package/strip-markdown.md) ^3.1.2
- [gatsby-core-utils](https://npm.io/package/gatsby-core-utils.md) ^1.3.14
- [@undataforum/components](https://npm.io/package/@undataforum/components.md) ^0.79.0
- [gatsby-source-filesystem](https://npm.io/package/gatsby-source-filesystem.md) ^2.3.23
- [@undataforum/gatsby-theme-base](https://npm.io/package/@undataforum/gatsby-theme-base.md) ^0.14.0

## Recent versions

- 0.12.0 (latest) — 2020-08-03
- 0.11.4 — 2020-03-27
- 0.11.3 — 2020-03-19
- 0.11.2 — 2020-03-19
- 0.11.1 — 2020-03-18
- 0.11.0 — 2020-03-13
- 0.10.0 — 2020-03-09
- 0.9.1 — 2020-01-31
- 0.9.0 — 2020-01-30
- 0.8.0 — 2020-01-14
- 0.7.6 — 2019-12-10
- 0.7.5 — 2019-12-02
- 0.7.4 — 2019-11-21
- 0.7.3 — 2019-11-21
- 0.7.2 — 2019-11-19
- … 11 more at https://npm.io/package/@undataforum/gatsby-theme-blog/versions

## README

# @undataforum/gatsby-theme-blog

A [Gatsby theme](https://www.gatsbyjs.org/docs/themes/) to create a blog with
post pages and a posts overview page. This theme can also be used for news
articles.

## Usage

### Theme options

| Key           | Default Value    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                |
| :------------ | :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `basePath`    | `/`              | Root url for all posts. Should be changed to `/blog` in most cases. `basePath` is used in Gatsby lifecycle methods to generate individual post pages and the posts overview page.                                                                                                                                                                                                                                                          |
| `contentPath` | `content/posts`  | Location of profile MDX files. The filename convention is `<slug>.md`, e.g. `the-power-of-new-data-sources.md`. If you do not set a slug in the frontmatter, the MDX file's base name, in this example `the-power-of-new-data-sources`, is used as slug. `contentPath` is used to configure plugin `gatsby-source-filesystem`. Any file in `contentPath` is part of the GraphQL `Mdx` collection.                                          |
| `assetPath`   | `content/assets` | Location of assets for blog posts. `assetPath` is used to configure plugin `gatsby-source-filesystem`. Any image in `assetPath` can be linked to a post by adding it to the frontmatter `images` array via relative path. Images can follow any file name convention you like.                                                                                                                                                             |
| `collection`  | `blog`           | The `collection` option is supplied to the `name` option of plugin `gatsby-source-filesystem` for the `contentPath` definition. This makes it possible to filter `File` nodes by `collection` using `sourceInstanceName`. If you configure this theme more than once in `gatsby-config.js`, you can use `collection` to distinguish different post collections, e.g. collection `blog` for a blog and collection `news` for news articles. |
| `profiles`    | `undefined`      | If `profiles` is not set, frontmatter `authors` is interpreted as an array of author names and rendered as such. If `profiles` is set, it refers to a specific collection of profiles created with `@undataforum/gatsby-theme-profiles`. In this case frontmatter `authors` is interpreted as array of author slugs that each reference a profile in the collection defined by the `profiles` option.                                      |

This example config shows how to configure two separate posts collections:

```
// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `@undataforum/gatsby-theme-blog`,
      options: {
        basePath: '/news',
        contentPath: '/content/news',
        assetPath: '/assets/news',
        collection: 'news'
      },
    },
        {
      resolve: '@undataforum/gatsby-theme-blog',
      options: {
        basePath: '/blog',
        contentPath: '/content/blog',
        assetPath: '/assets/blog',
        collection: 'blog'
      },
    },
  ],
}
```

### MDX frontmatter

Frontmatter keys for MDX posts located in `contentPath`. The YAML type of each
key corresponds to the GraphQL type listed in the following section.

| Key           | Required | Description                                                                                                                                                                                                                |
| :------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title`       | yes      | Post title.                                                                                                                                                                                                                |
| `date`        | yes      | Date in `yyyy-MM-dd` format. This is the date as it should appear on the website. There is no timezone magic happening anywhere.                                                                                           |
| `authors`     | no       | If theme option `profiles` is not set, this is a list of author names. If theme option `profiles` is set, this is a list of author slugs that references profiles from the collection provided in theme option `profiles`. |
| `slug`        | no       | The default slug is the post MDX file's base name. This value overrides the default.                                                                                                                                       |
| `description` | no       | The default description for SEO purposes is the first paragraph in a post MDX file. This value overrrides the default.                                                                                                     |
| `images`      | no       | List of relative paths to images that can be included into a post via MDX.                                                                                                                                                 |

### GraphQL Profile type

This theme adds GraphQL type `Post` which can be queried with `post` and
`allPost` queries. Type `Post` makes no assumptions about what the underlying
data source is.

| Field         | Type                          | Description                                                                                    |
| :------------ | :---------------------------- | :--------------------------------------------------------------------------------------------- |
| `id`          | `ID!`                         | Gatsby node GUID.                                                                              |
| `slug`        | `ID!`                         | Alternative ID used for querying and building the graph.                                       |
| `collection`  | `String!`                     | Distinguish separate post collections.                                                         |
| `title`       | `PostTitle!`                  | Text and compiled MDX variants of post title.                                                  |
| `date`        | `Date!`                       |                                                                                                |
| `authors`     | `[String!]!` or `[Profile!]!` | Type depends on theme option `profiles`.                                                       |
| `description` | `PostDescription!`            | Text and compiled MDX variants of post description.                                            |
| `body`        | `String!`                     | A string representation of the body of the profile page. For MDX pages this is the MDX `body`. |
| `images`      | `[File!]`                     | Relative paths to images.                                                                      |
| `path`        | `String!`                     | Path to generated page.                                                                        |

---
_Source: https://npm.io/package/@undataforum/gatsby-theme-blog · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
