Community Plugin
View plugin on GitHub@undataforum/gatsby-theme-blog
A Gatsby theme 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 /blogin most cases.basePathis 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 examplethe-power-of-new-data-sources, is used as slug.contentPathis used to configure plugingatsby-source-filesystem. Any file incontentPathis part of the GraphQLMdxcollection. | 
| assetPath | content/assets | Location of assets for blog posts. assetPathis used to configure plugingatsby-source-filesystem. Any image inassetPathcan be linked to a post by adding it to the frontmatterimagesarray via relative path. Images can follow any file name convention you like. | 
| collection | blog | The collectionoption is supplied to thenameoption of plugingatsby-source-filesystemfor thecontentPathdefinition. This makes it possible to filterFilenodes bycollectionusingsourceInstanceName. If you configure this theme more than once ingatsby-config.js, you can usecollectionto distinguish different post collections, e.g. collectionblogfor a blog and collectionnewsfor news articles. | 
| profiles | undefined | If profilesis not set, frontmatterauthorsis interpreted as an array of author names and rendered as such. Ifprofilesis set, it refers to a specific collection of profiles created with@undataforum/gatsby-theme-profiles. In this case frontmatterauthorsis interpreted as array of author slugs that each reference a profile in the collection defined by theprofilesoption. | 
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-ddformat. This is the date as it should appear on the website. There is no timezone magic happening anywhere. | 
| authors | no | If theme option profilesis not set, this is a list of author names. If theme optionprofilesis set, this is a list of author slugs that references profiles from the collection provided in theme optionprofiles. | 
| 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. |