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 ( import (
"embed" "embed"
"log" "log"
"mime"
"net/http" "net/http"
"os" "os"
) )
@@ -15,6 +16,10 @@ import (
var web embed.FS var web embed.FS
func main() { 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") root := os.Getenv("KONTRA_CONTENT")
if root == "" { if root == "" {
root = "content" root = "content"

View File

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

View File

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