Fibery as a CMS: how we automatically publish posts from Fibery to our Gatsby blog

Fibery as a CMS is an interesting idea to explore. We run our Fibery blog in Gatsby with static .md files, but Fibery can produce content in Markdown format. We decided to automate blog posts publishing and integrated Fibery with Gatsby.

Blog space structure

We created Blog Space in our Fibery account (you can install it into your workspace using this template link). Blog space has three databases:

From the user perspective everything is easy: you just create new Article entity, and write a text. Here is the list of Articles in Blog Space with one article opened on the right:

Tech details

The article database has “Publish” Action Button. This button triggers the blog CI pipeline. The CI pipeline fetches data content using a JavaScript script from Fibery and writes the markdown file to the file system. Then, it triggers the Gatsby build and pushes the new blog to the production cluster.

Here is the article in our real blog, and here is the article in Blog Space (pay attention to some fields on the right that we use to add tags, date and other meta to the blog post):

The main idea behind the script is to traverse a Fibery document, fetch images from Fibery, save them to the file system, replace the Fibery link with the local file link, and transform the document into a specific format that a blogging system can use as a source for an article.

This script implemented naive approach for fetching data and doesn’t handle rate limit api error. This script needs improvements such adding cache for already fetched images and adding API request limit to fibery.

Quote from Michael, who writes a lot:

Now I can write and update articles really fast without any special knowledge. While I enjoyed VSCode and Markdown, Fibery text editor is much more pleasant experience. You can add images faster, don’t think how to format this and that, use AI right here to make proofreading and corrections. It really saves time and removes a barrier for blog posting.


  1. Install Blog Space from Blog template
  2. You should have Gatsby blog and some pipeline in GitLab that updates it on commit.
  3. Create The CI pipeline that fetches data content using a JavaScript script from Fibery and writes the markdown file to the file system. Then, it triggers the Gatsby build and pushes the new blog to the production cluster.
  4. The article database has an automation button. This button triggers the blog CI pipeline, here is the Script that you should put into button Action (provide correct pipeline trigger URL)
// HTTP allows to send requests to external services
const http = context.getService('http');
const date = +(new Date());

await http.postAsync(`[BLOG_VERSION]=${date}`);
  1. Create new article and publish it via a button click.

Here is how I setup this with gatsby-starter-blog (elaboration on step 1 and 2):

npm update
npm install -g gatsby-cli
npx gatsby new gatsby-starter-blog
cd gatsby-starter-blog

Create .env on root:


Save my modified script as read-content-from-fibery.mjs on root. Note that the import section needs to be like this:

import "dotenv/config"
import got from "got"
import process from "node:process"
import { extname, basename } from "node:path"
import unified from "unified"
import remarkParse from "remark-parse"
import visit from "unist-util-visit"
import { pipeline as streamPipeline } from "node:stream/promises"
import { createWriteStream } from "node:fs"
import { mkdir, writeFile, readdir } from "node:fs/promises"
import toMarkdown from "mdast-util-to-markdown"

and line 259 should be:

  const articleDir = `content/blog/${article.slug}`

Create .gitlab-ci.yml on root:

image: node:latest
    - node_modules/
    # Enables git-lab CI caching. Both .cache and public must be cached, otherwise builds will fail.
    - .cache/
    - public/
    - yarn install
    - yarn add react-scripts
    - node read-content-from-fibery.mjs
    - ./node_modules/.bin/gatsby build --prefix-paths
      - public
    - main


node read-content-from-fibery.mjs
npm run develop

You should see new articles getting fetched to content\blog folder, and your result is now ready in http://localhost:8000/. If everything works, then delete the articles you just download, and you can now push your repo to Gitlab.

If you have time, I recommend take a look at Getting Started | Gatsby to learn more


Link to repository with the example fibery-community / gatsbyjs-example · GitLab
This is the commit which adds support fibery as source of blog content

I cant use this for embed image or video, can it be embed ?
Ex: I add an attachment as cover in fibery

and here’s result in my website

You just need to add a image in a rich text and this image will be embed in our blog.
The article in Fibery
The article in the blog

1 Like

Yesterday I tried to delete and custome some field and got eror in gitlab

Do we have any way to change field in this template

  • I have People database so I dont wanna use Author db in this template
  • also I have MOC database so I dont wanna use Tags field (multi select) in this template
  • I have PKM database so I dont wanna use Question db in this template

I mean I dont wanna have seperate Space (Blog) with our PKM Space, so I wanna merge them and use own database

You can modify this graphQl request Fibery as CMS · GitHub
. | Fibery

1 Like

I wonder why you don’t use TypeScript for this? Also any particular reason for choosing Gatsby?

We started using Gatsby in 2020. Gatsby was the most popular static blog system at that time. The default template used JavaScript as the main language. We don’t see any advantage in migrating our blog to TypeScript, maybe in the future.

can you share more on why you don’t see TS has any advantage? I can’t imagine my life without it

Typescript will not significantly improve our blog, but we will need to invest time in transitioning to it. However, most of Fibery services use Typescript, and we begin new services with Typescript.

1 Like

Not everyone thinks all Javascript should be Typescript - myself included.

1 Like

The current button let us immediately trigger data from fibery to gitlab.
So about {Date} field, Do we have any way to set auto schedule for publishing. I wanna set an automation for this On exactly date field on time