Siftware Dev

Git sources

A Docs folder can take its pages from a git repository. Markdown files become pages, subdirectories become subfolders, and every push keeps the folder current. The repository stays the place to edit; the app is where people read.

A GitLab repository on the left holds a manual directory with _folder.md, getting-started.md and a clients subdirectory with companies.md and an image. A push to the folder's ref calls the webhook, which runs a sync; an hourly pull is the fallback. On the right, the Docs folder in the app gets a folder intro, a Getting started page, a Clients subfolder with a Companies page, and the image copied in. Edit in git on a page opens its source file. Synced pages are read-only in the app; a deleted file archives its page, and detaching keeps the pages as ordinary docs.

What you can do

How to

Attaching, syncing and detaching are done through the API (/api/v1), with a personal API token that holds knowledge:write (Settings > You > Connections > API tokens). There is no attach form in the app.

Attach:

  1. Find the folder's slug or id in Docs.
  2. Send POST /api/v1/articles/<folder>/source with:
    • provider: gitlab
    • base_url: the git host, for example https://git.example.com
    • repository: the project path, for example acme/handbook
    • ref: a branch, tag or commit id, for example main
    • path: optional, the directory inside the repository, for example manual
    • token: a GitLab access token that can read the repository
  3. The response carries webhook_url and webhook_secret. The secret is shown once, in this response only. Copy it before closing the response.
  4. The first sync starts straight away.

Add the push webhook in the git host:

  1. Open the repository's webhook settings.
  2. Set the URL to webhook_url from the attach response.
  3. Paste webhook_secret as the secret token.
  4. Trigger on push events. Save.

A push to the folder's ref queues a sync. A push to another branch is ignored.

Other actions:

Repository layout:

manual/
  _folder.md          the folder's intro
  getting-started.md  a page
  clients/            a subfolder
    _folder.md
    companies.md
    img/
      company-page.png

Front matter, at the top of each file:

---
key: clients.companies
title: Companies
order: 10
---
Key Use
key Stable id. A file renamed or moved with the same key keeps its page, slug, links and revisions. Without key, the path is the identity and a rename archives the old page and makes a new one.
title Page title. Without it, the first # heading, else the file name.
order Position among siblings, a whole number. Without it, name order.
slug The page address, set on first sync only.
visibility personal, project or internal. Optional, and never wider than the folder.

Limits

Related

Markdown version