Decap Netlify tips

Decap CMS https://github.com/decaporg/decap-cms formerly known as https://github.com/netlify/netlify-cms

Enable users to sign in with Github or external provider and create posts on phone without git commands https://www.netlifycms.org/docs/add-to-your-site/#authentication

Decap Installation

Lets use jekyll https://decapcms.org/docs/jekyll/ Create two files

# admin/index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="robots" content="noindex" />
    <title>Content Manager</title>
  </head>
  <body>
    <!-- Include the script that builds the page and powers Decap CMS -->
    <script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
  </body>
</html>

and

# admin/config.yml
backend:
  name: git-gateway
  branch: master

publish_mode: editorial_workflow

media_folder: "_images"
public_folder: "assets/images"

collections:
  - name: "blog"
    label: "Blog"
    folder: "_posts"
    create: true 
    slug: "---"
    # identifier_field: latin
    editor:
      preview: false
    fields:
      - {label: "Layout", name: "layout", widget: "hidden", default: "post"}
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Latin", name: "latin", widget: "string", hint: 'Ovaj se koristi za URL posto ћирилица nije uobicajena za linkove. Kad se postavi, vise se ne moze promenuti'}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Author", name: "author", widget: "select", options: ['vladan', 'slobodan', 'dragutin', 'darko', 'sreten', 'branislav']}
      - {label: "Body", name: "body", widget: "markdown"}

Enable backend on netlify

Enable in Site configuration > Identity (also External providers like Google) and set the Identity > Registration > Registration is invite only so you can invite users on app.netlify.com/sites/my-site/identity note that Open users does not count to the free tier usage as seen on app.netlify.com/sites/my-site/configuration/identity) Also enable Site configuration > Identity > Services > Git Gateway

Error when I could not enable Identity and see this error message

{"code":400,"msg":"An instance with that UUID already exists"}

I solved by removing the site and adding the site again.

Error that you do not see all posts, probably the issue is in admin/config.yml on backend > branch . Make sure branch is the one you are using for the pages.

Error when working on locally and see window “Looks like you’re running a local server. Please let us know the URL of your Netlify site.” which appears briefly and then closes. Solution is to wait a few seconds (in console there is log “Manually initializing identity widget” and than click on “Login with Netlify Identity”. Note that when entering url, it will redirect, so you need to again enter 127.0.0.1:4000 in url.

Admin config

https://decapcms.org/docs/configure-decap-cms/

Collections Fields Widgets

When you do not see correct order when Sort by Publish Date than you do not have date: filled on each post. Solution is to add date: 2019-07-27T07:33:00.000Z that matches the filename, and again select sorting option.

https://decapcms.org/docs/widgets/