Orga

Generate Static Website With Gatsby

Setup

Install the plugin.

   npm install gatsby-transformer-orga

Add it to your plugins list.

     // In your gatsby-config.js
     plugins: [`gatsby-transformer-orga`]

Parsing

Files with .org extension will be considered org files. Each org file is parsed into a node of type OrgFile. Each OrgFile node will have one or more OrgContent nodes, depending on the mode (section or file based).

Modes

gatsby-transformer-orga plugin provides 2 ways to generate your content from your org-mode source files.

  • one document per org-mode file
  • one document per section (sub-tree)

The former is the default option. To enable section based generation, add ORGA_PUBLISH_KEYWORD to your org file, and sections with matching keyword will be transformed into a standalone document. E.g.

       ,#+ORGA_PUBLISH_KEYWORD: DONE

       ,* DONE My First Post
         CLOSED: [2018-12-14 Fri 15:44]

         ...

       ,* TODO A Draft

In this case, the first section will become a post. The second won't.

Data Mapping Table (File Based)

meta fieldfirst optionsecond option
title#+TITLE"Untitled"
export_file_name#+EXPORT_FILE_NAMEthe file name
category#+CATEGORYN/A
tags#+TAGSN/A

All the rest of the In-buffer Settings will be automatically added to the meta field. And they are queryable from Gatsby's graphql interface. They are lower-cased for consistency purpose.

Data Mapping Table (Section Based)

meta fieldfirst optionsecond option
titlefirst headline textN/A
export_file_nameEXPORT_FIEL_NAME propertysanitised title
categoryCATEGORY propertythe file name
tagsheadline tagsN/A

All the rest of the Properties of the headline will be automatically added to the meta field. And they are queryable from Gatsby's graphql interface. They are lower-cased for consistency purpose.

Query Examples

To get all content node (OrgContent):

     {
       allOrgContent: {
     edges: {
       node: {
         html
         meta {
           title
           tags
           category
         }
       }
     }
       }
     }