admin: fix Decap render (script in body, yaml MIME), Gitea OAuth backend + CORS, simple workflow

This commit is contained in:
sam
2026-09-09 07:42:03 +10:00
parent 9ca027c86f
commit 2ec6a358c2
3 changed files with 19 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ package main
import (
"embed"
"log"
"mime"
"net/http"
"os"
)
@@ -15,6 +16,10 @@ import (
var web embed.FS
func main() {
// Decap CMS requires config.yml served as a YAML content type (it checks the header).
_ = mime.AddExtensionType(".yml", "application/yaml")
_ = mime.AddExtensionType(".yaml", "application/yaml")
root := os.Getenv("KONTRA_CONTENT")
if root == "" {
root = "content"

View File

@@ -1,23 +1,22 @@
# Kontra Admin — Decap CMS
# Serves the same content repo that the Go binary renders.
# Editor saves -> git commit -> Gitea push -> 30s timer on .13 pulls -> site live.
# Editor saves -> git commit -> Gitea push -> 30s pull loop in the site container -> live.
backend:
name: git-gateway
name: gitea
repo: sam/kontra-content # Gitea repo (org/user + name)
branch: main
# Uses the "Decap CMS" OAuth / git-gateway app on Gitea.
# Swap to name: github / gitlab / gitea and a token if you prefer PAT-based.
local_backend: false
app_id: ffe1375f-1a1b-40d2-9602-27b0f5b470fe # from Gitea OAuth application
base_url: https://gitea.lab.audasmedia.com.au
api_root: https://gitea.lab.audasmedia.com.au/api/v1
auth_endpoint: login/oauth/authorize
clear_credentials_before_refresh: false
# Media goes to Garage S3 via shortcode at render time; Decap just stores the
# object key inside the .md. If you instead want files committed to the repo,
# point media_folder at content/media and public_folder at /media.
media_folder: "" # no local uploads by default
public_folder: ""
media_library:
name: ""
config: {}
# ------------------------------------------------------------------
# Collections
@@ -26,7 +25,7 @@ collections:
- name: articles
label: Articles
label_singular: Article
folder: content/subjects
folder: subjects
create: true
slug: "{{slug}}"
path: "{{slug}}/{{slug}}"
@@ -48,7 +47,7 @@ collections:
- name: subjects
label: Subjects
label_singular: Subject
folder: content/subjects
folder: subjects
create: true
slug: "{{slug}}"
path: "{{slug}}/_subject"
@@ -61,7 +60,7 @@ collections:
- name: pages
label: Pages
label_singular: Page
folder: content/pages
folder: ../pages
create: true
slug: "{{slug}}"
fields:
@@ -78,6 +77,3 @@ editor:
preview: false
frame: false
publish_mode: editorial_workflow
show_preview_links: false

View File

@@ -4,14 +4,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kontra — Admin</title>
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
</head>
<body>
<script>
// Tell Decap where the config lives (served from the same /web/admin/ tree).
window.CMS_ENDPOINT = '/web/admin';
window.CMS_CONFIG = '/web/admin/config.yml';
</script>
<!-- Decap injects the login screen / editor here -->
<!-- Decap mounts into the DOM; script must load after <body> exists.
It auto-loads config.yml from the same directory as this page. -->
<script src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
</body>
</html>