Add Gitea Actions deploy workflow and server configuration
Some checks failed
Deploy to Server / deploy (push) Failing after 1m49s
Some checks failed
Deploy to Server / deploy (push) Failing after 1m49s
- Add basePath /admin to Next.js config for path-based routing - Add .gitea/workflows/deploy.yml for CI/CD via Gitea Actions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,21 @@
|
||||
export const getBaseUrl = () =>
|
||||
process.env.NEXT_PUBLIC_RUSTYCMS_API_URL || "http://127.0.0.1:3000";
|
||||
|
||||
/**
|
||||
* Expand relative /api/assets/ paths in text (e.g. markdown) to full URLs for preview/display.
|
||||
* Idempotent: already-expanded base URL is preserved.
|
||||
*/
|
||||
export function expandAssetUrlsInText(text: string, baseUrl: string): string {
|
||||
const base = baseUrl.replace(/\/+$/, "");
|
||||
const fullPrefix = `${base}/api/assets/`;
|
||||
if (!text.includes("/api/assets/")) return text;
|
||||
const placeholder = "\x00__ASSET_BASE__\x00";
|
||||
return text
|
||||
.replaceAll(fullPrefix, placeholder)
|
||||
.replaceAll("/api/assets/", fullPrefix)
|
||||
.replaceAll(placeholder, fullPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively collapse absolute asset URLs to relative paths so the admin
|
||||
* keeps and displays /api/assets/... and the backend stores relative.
|
||||
@@ -14,10 +29,11 @@ export function collapseAssetUrlsForAdmin(
|
||||
value: unknown,
|
||||
baseUrl: string
|
||||
): unknown {
|
||||
const prefix = `${baseUrl.replace(/\/+$/, "")}/api/assets/`;
|
||||
const base = baseUrl.replace(/\/+$/, "");
|
||||
const prefix = `${base}/api/assets/`;
|
||||
if (typeof value === "string") {
|
||||
if (value.startsWith(prefix)) return `/api/assets/${value.slice(prefix.length)}`;
|
||||
return value;
|
||||
if (!value.includes(prefix)) return value;
|
||||
return value.replaceAll(prefix, "/api/assets/");
|
||||
}
|
||||
if (Array.isArray(value)) return value.map((v) => collapseAssetUrlsForAdmin(v, baseUrl));
|
||||
if (value != null && typeof value === "object") {
|
||||
|
||||
Reference in New Issue
Block a user