Gatsby With Orga

Config and Options

November 10, 2020
310 words
1 minutes

All configuration details are in your gatsby-config.js file.

Site Metadata

There's a set of website metadata to customize. You can customize it in gatsby-config.js file.

siteMetadata: {
  title: `Blog Title Placeholder`, // website default title
  siteUrl: `https://orga.js.org`, // domain of your site
  author: `Name Placeholder`, // your name
  description: `Description placeholder`, // description of website, for SEO
  twitter: 'xiaoxinghu', // your twitter handle, you can set it to false or ignore it to get rid of the "Tweet this." button
  social: [ // your social badges, in your bio
    { name: 'twitter', url: 'https://twitter.com/xiaoxinghu' },
    { name: 'website', url: 'https://huxiaoxing.com' },
    { name: 'email', url: 'mailto:contact@huxiaoxing.com' },
  ],
},

Post Metadata

Each post has a set of metadata. Here is how it looks like.

interface Metadata {
  title: string;
  date: Date;
  category: string;
  tags: string[];
  export_file_name: string;
}

These are the mandatory properties, you can expand it by simply adding PROPERTIES to the headline or by adding in-buffer settings.

E.g. in your org file:

,* hello world
  :PROPERTIES:
  :IMAGE:    ./images/dog.png
  :END:

You can find more details about Post Metadata in About Your Org Files.

Options

You can customize a set of options in your gatsby-config.js file. Here is the list.

Option Type Default Value
contentPath String 'content'
filter Function () => true
pagination Number 0
columns Number 2
indexPath String '/'
imageMaxWidth Number 1380
categoryIndexPath Function (category) => `/${category}`
tagIndexPath Function tag => `/:${tag}:`
slug Function ({ export_file_name }) => `/${export_file_name}`
postRedirect Function () => []
preset String 'orga-theme-ui-preset'

contentPath

Where your org files located. You can use relative path like: ../notes.

filter

A function that decides whether a OrgContent should be ignored. An example would be:

{
  resolve: `gatsby-theme-blorg`,
  options: {
    filter: ({ keyword }) => keyword === 'PUBLISHED' || keyword === 'DONE',
    // other options...
  },
},

Parameters

  • Post Metadata

Returns

  • true (include) or false (exclude)

pagination

If you have lots of posts, you are going to want to enable pagination. The value is max posts per page on the index pages. You will get slugs like domain.com/1, domain.com/2 for the index pages. For category links domian.com/emacs/1, domian.com/emacs/2...

columns

Number of columns for index pages.

indexPath

Path for index page. Set to false to disable.

categoryIndexPath

Category index page path. Parameter of the function is the category. Set to false to disable. Or return false conditionally to disable certain category.

slug

Generate slug for posts, with post metadata as input.

preset

theme-ui preset.

Read more stories about "getting-started" ->