use local git repo - basic features seem to work
Some checks are pending
Deploy Next.js site to Pages / build (push) Waiting to run
Deploy Next.js site to Pages / search-tests (push) Blocked by required conditions
Deploy Next.js site to Pages / deploy (push) Blocked by required conditions

This commit is contained in:
Gerhard Scheikl
2026-04-01 20:18:20 +02:00
parent fc107d576c
commit 982f4109cf
7 changed files with 29 additions and 160 deletions

View File

@@ -1,45 +1,44 @@
import {
createDatabase,
createLocalDatabase,
FilesystemBridge,
IsomorphicBridge,
} from "@tinacms/datalayer";
import { RedisLevel } from "upstash-redis-level";
import { Redis } from "@upstash/redis";
import { GiteaGitProvider } from "./gitea-git-provider";
const isLocal = process.env.TINA_PUBLIC_IS_LOCAL === "true";
const branch = process.env.TINA_GIT_BRANCH || "main";
function createProductionDatabase() {
const giteaUrl = process.env.GITEA_URL;
const giteaToken = process.env.GITEA_TOKEN;
const giteaOwner = process.env.GITEA_OWNER;
const giteaRepo = process.env.GITEA_REPO;
const kvUrl = process.env.KV_REST_API_URL;
const kvToken = process.env.KV_REST_API_TOKEN;
if (!giteaUrl || !giteaToken || !giteaOwner || !giteaRepo) {
if (!kvUrl || !kvToken) {
// During tinacms build (schema generation), env vars may not be available.
// Fall back to local database for the build step.
return createLocalDatabase();
}
return createDatabase({
gitProvider: new GiteaGitProvider({
owner: giteaOwner,
repo: giteaRepo,
token: giteaToken,
branch,
baseUrl: giteaUrl,
}),
gitProvider: {
onPut: async () => {},
onDelete: async () => {},
},
databaseAdapter: new RedisLevel<string, Record<string, unknown>>({
redis: new Redis({
url: kvUrl || "http://localhost:8079",
token: kvToken || "example_token",
url: kvUrl,
token: kvToken,
}) as any,
debug: process.env.DEBUG === "true" || false,
}),
bridge: new FilesystemBridge(process.cwd()),
bridge: new IsomorphicBridge(process.cwd(), {
gitRoot: process.cwd(),
author: {
name: "TinaCMS",
email: "cms@linumiq.com",
},
commitMessage: "Content updated via TinaCMS",
}),
namespace: branch,
});
}