@brightsideoy/kama 0.1.0-alpha.143 → 0.1.0-alpha.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.wrangler/state/v3/cache/default/blobs/4de32ec3e619aa3f9acad3fb1a2528209381347d1cbb86e939e08724f5b35bc4000001a0b2b5b216 +0 -0
- package/.wrangler/state/v3/cache/default/blobs/5f895e5810a26a6319bbadde9d751e5b10faae6e141db1c454c5f53b3e725591000001a0b2b624a4 +0 -0
- package/.wrangler/state/v3/cache/default/blobs/74744186327d8aaf1c6078e50bc561135fd90690c96bd4b733035d0cb3fedb94000001a0b2b5be6b +0 -0
- package/.wrangler/state/v3/cache/default/blobs/79c1c81c1ddcd49f49eb27b9197ae0160c3a7981f308aee2ae972653de1b3668000001a0b2b60e76 +0 -0
- package/.wrangler/state/v3/cache/default/blobs/7cd29a3bd95a88e7e896a4ae253758cd9e4bde78fc371077f3fef974cd11c64d000001a0b098ff88 +0 -0
- package/.wrangler/state/v3/cache/default/blobs/7ecc4caad58c7ee119c02adb84132eaa691b9a171f932ab1c17e0f95c3fed2a8000001a0b2b5bf5e +0 -0
- package/.wrangler/state/v3/cache/default/blobs/81928c274111d2c3cbd3d7174136a2fdce83e267da8f8d0caf60d650396197f5000001a0b098de9d +0 -0
- package/.wrangler/state/v3/cache/default/blobs/8c3aa6f6625d7c0d682cb498e6715355aec1905909b04ead5e85adbca3989b19000001a0b098e4ac +0 -0
- package/.wrangler/state/v3/cache/default/blobs/97205d84c3e4399f6f51295e8381b21f2a8810cdaecc0ab13f2cadf712fae5f4000001a0b339609d +0 -0
- package/.wrangler/state/v3/cache/default/blobs/b48d02100b8f1a9520a209628a0778a0f9e0f4ce0643f8d59b3888bbd0f85fc2000001a0b2b63647 +0 -0
- package/.wrangler/state/v3/cache/default/blobs/cf30c018e70dad1c6859277e4361da657b79adf34e60cb05885eb32951fbbafc000001a0b09b168f +0 -0
- package/.wrangler/state/v3/cache/default/blobs/d0d796d0fe4efd55f61e0c3b8d30170a89703669a52854687186a66304adbf8a000001a0b2b6244d +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/9f458c07675338a7426a7b81ac4fb1baf92d034efbcaaf4336379640ed744ded.sqlite +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/7cfce387cae19c0dfbb9cc4f2a9c353f60ca0a80fabd0b2e2837d152b58feaaa.sqlite +0 -0
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/metadata.sqlite-wal +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/metadata.sqlite-wal +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/a590acd76969f996ec6e4b599c3c09f58c283a76f2d61392b5d3046caf557602.sqlite +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/a590acd76969f996ec6e4b599c3c09f58c283a76f2d61392b5d3046caf557602.sqlite-shm +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/a590acd76969f996ec6e4b599c3c09f58c283a76f2d61392b5d3046caf557602.sqlite-wal +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/metadata.sqlite +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/observability/miniflare-wobs-trace-store/metadata.sqlite-wal +0 -0
- package/.wrangler/state/v3/r2/kama-media/blobs/1c7705701fba41f9a2683025d40393711daffc55d32172088a62d8999017e9c6000001a0b339607a +0 -0
- package/.wrangler/state/v3/r2/kama-media/blobs/1ee266c53f586a4a57a1d21be291e34bb2e2236c15e43ae30497f6054290f01d000001a0b2b6248c +0 -0
- package/.wrangler/state/v3/r2/kama-media/blobs/6db1f8204b6d125f0911b3e42022258cc7e1c37a95c2ce7f5c7f14da31d408ec000001a0b2b60e1f +0 -0
- package/.wrangler/state/v3/r2/kama-media/blobs/97b86f251c5d30df5e1eab8662cab83f5f7c4583ad14fd2d5ea99f16fdcfd6ef000001a0b2b62482 +0 -0
- package/.wrangler/state/v3/r2/miniflare-R2BucketObject/9ffe30cff37d40b366f64100a8f041c0a1e5aee78708ba90b9ef4ca6a6b2d883.sqlite +0 -0
- package/.wrangler/state/v3/r2/miniflare-R2BucketObject/metadata.sqlite +0 -0
- package/.wrangler/state/v3/r2/miniflare-R2BucketObject/metadata.sqlite-shm +0 -0
- package/.wrangler/state/v3/r2/miniflare-R2BucketObject/metadata.sqlite-wal +0 -0
- package/README.md +16 -37
- package/bin/cli.js +187 -139
- package/definitions/_page.yaml +52 -0
- package/dist/assets/index-BSBvGvQz.css +1 -0
- package/dist/assets/index-RzfH6iq3.js +162 -0
- package/dist/dist-CZEgSuN0.js +8674 -0
- package/dist/index.html +2 -2
- package/dist/index.js +6857 -11240
- package/dist/schema-compiler.js +38 -0
- package/npm-test.sh +75 -0
- package/package.json +14 -10
- package/schema.sql +3 -2
- package/templates/astro-starter/src/components/blocks/ImageBlock.astro +20 -56
- package/templates/astro-starter/src/components/global/Header.astro +19 -12
- package/templates/astro-starter/src/components/ui/KamaImage.astro +49 -73
- package/templates/astro-starter/src/pages/[...slug].astro +16 -43
- package/templates/astro-starter/src/pages/media/[...path].ts +8 -1
- package/wrangler.json +22 -0
- package/dist/assets/index-BcbVkck_.js +0 -162
- package/dist/assets/index-Bv7fPRX7.css +0 -1
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
// src/pages/[...slug].astro
|
|
3
2
|
import StandardLayout from "../layouts/StandardLayout.astro";
|
|
4
3
|
import SkeletonLayout from "../layouts/SkeletonLayout.astro";
|
|
5
4
|
import BlockRenderer from "../components/blocks/BlockRenderer.astro";
|
|
6
5
|
import Breadcrumb from "../components/global/Breadcrumb.astro";
|
|
7
6
|
import { getNodeByPath, getChannelId, getTree, getTreeId } from "../lib/cms";
|
|
8
7
|
import type { NodeResponse, TreeNode } from "../lib/cms";
|
|
9
|
-
import { env } from "cloudflare:workers";
|
|
10
8
|
|
|
11
9
|
export const prerender = false;
|
|
12
10
|
|
|
13
11
|
const { slug } = Astro.params;
|
|
14
|
-
|
|
15
|
-
// 🎯 Extract Preview & Revision parameters from the URL
|
|
16
12
|
const searchParams = Astro.url.searchParams;
|
|
17
13
|
const isPreview = searchParams.get("preview") === "true";
|
|
18
14
|
const revisionId = searchParams.get("revisionId");
|
|
@@ -22,7 +18,6 @@ Astro.response.headers.set(
|
|
|
22
18
|
"no-store, no-cache, must-revalidate, proxy-revalidate",
|
|
23
19
|
);
|
|
24
20
|
|
|
25
|
-
// 1. STATIC ASSET CHECK
|
|
26
21
|
const staticExts = [
|
|
27
22
|
".ico",
|
|
28
23
|
".png",
|
|
@@ -42,20 +37,11 @@ if (isStaticAsset) {
|
|
|
42
37
|
return new Response(null, { status: 404 });
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Extract environment configuration & fallback slug
|
|
51
|
-
const envHomeSlug = import.meta.env.PUBLIC_HOME_SLUG;
|
|
52
|
-
const workerHomeSlug = (workerEnv as any).PUBLIC_HOME_SLUG;
|
|
53
|
-
const homeSlug = String(envHomeSlug || workerHomeSlug || "home").trim();
|
|
54
|
-
|
|
55
|
-
const envApiUrl = import.meta.env.PUBLIC_API_URL;
|
|
56
|
-
const workerApiUrl = workerEnv.PUBLIC_API_URL;
|
|
57
|
-
const baseApiUrl = String(envApiUrl || workerApiUrl || "http://localhost:8787");
|
|
58
|
-
|
|
40
|
+
// 🎯 DUAL-ARCHITECTURE ENV RESOLUTION (No CF Imports, No runtime.env!)
|
|
41
|
+
const homeSlug = String(import.meta.env.PUBLIC_HOME_SLUG || "home").trim();
|
|
42
|
+
const baseApiUrl = String(
|
|
43
|
+
import.meta.env.PUBLIC_API_URL || "http://localhost:8787",
|
|
44
|
+
);
|
|
59
45
|
const cleanApiUrl = baseApiUrl.endsWith("/")
|
|
60
46
|
? baseApiUrl.slice(0, -1)
|
|
61
47
|
: baseApiUrl;
|
|
@@ -67,32 +53,25 @@ const customFetch = async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
|
67
53
|
const urlObj = new URL(urlStr);
|
|
68
54
|
urlObj.searchParams.set("_t", Date.now().toString());
|
|
69
55
|
|
|
70
|
-
// Inject Revision ID and Preview flag if we are time-traveling
|
|
71
56
|
if (revisionId) urlObj.searchParams.set("revisionId", revisionId);
|
|
72
57
|
if (isPreview) urlObj.searchParams.set("preview", "true");
|
|
73
58
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (cmsWorker && typeof cmsWorker.fetch === "function") {
|
|
87
|
-
return cmsWorker.fetch(req);
|
|
88
|
-
}
|
|
89
|
-
return fetch(req);
|
|
59
|
+
return fetch(
|
|
60
|
+
new Request(urlObj.toString(), {
|
|
61
|
+
...init,
|
|
62
|
+
cache: "no-store",
|
|
63
|
+
headers: {
|
|
64
|
+
...init?.headers,
|
|
65
|
+
"X-Bypass-Cache": "true",
|
|
66
|
+
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
90
70
|
};
|
|
91
71
|
|
|
92
72
|
const channelId = getChannelId();
|
|
93
73
|
const treeId = getTreeId();
|
|
94
74
|
|
|
95
|
-
// 3. PATH RESOLUTION
|
|
96
75
|
const rawSlug = Array.isArray(slug) ? slug.join("/") : slugStr;
|
|
97
76
|
const pathParts = rawSlug.split("/").filter(part => part.trim() !== "");
|
|
98
77
|
|
|
@@ -100,14 +79,12 @@ let pageData: NodeResponse | null = null;
|
|
|
100
79
|
let navTree: TreeNode[] = [];
|
|
101
80
|
let targetSlug = pathParts.join("/");
|
|
102
81
|
|
|
103
|
-
// 🎯 FETCH TREE FIRST (to resolve root page if visiting '/')
|
|
104
82
|
try {
|
|
105
83
|
navTree = await getTree(treeId, channelId, customFetch);
|
|
106
84
|
} catch (err) {
|
|
107
85
|
console.error(`❌ [SSR Error] Failed to fetch tree "${treeId}":`, err);
|
|
108
86
|
}
|
|
109
87
|
|
|
110
|
-
// 🎯 DYNAMIC HOME SLUG RESOLUTION
|
|
111
88
|
if (!targetSlug) {
|
|
112
89
|
const rootTreeSlug =
|
|
113
90
|
navTree && navTree.length > 0
|
|
@@ -116,7 +93,6 @@ if (!targetSlug) {
|
|
|
116
93
|
targetSlug = rootTreeSlug || homeSlug;
|
|
117
94
|
}
|
|
118
95
|
|
|
119
|
-
// 🎯 FETCH NODE DATA
|
|
120
96
|
try {
|
|
121
97
|
pageData = await getNodeByPath(targetSlug, channelId, isPreview, customFetch);
|
|
122
98
|
} catch (err) {
|
|
@@ -144,13 +120,10 @@ const isHomePage =
|
|
|
144
120
|
pathParts.length === 0;
|
|
145
121
|
|
|
146
122
|
const normalizedSlug = isHomePage ? "" : targetSlug;
|
|
147
|
-
|
|
148
123
|
const headerBlocks = content?.header || [];
|
|
149
124
|
const mainBlocks = content?.content || [];
|
|
150
125
|
const sidebarBlocks = content?.sidebar || [];
|
|
151
126
|
const hasSidebar = sidebarBlocks.length > 0;
|
|
152
|
-
|
|
153
|
-
// 🎯 Detect if this node is a standalone Page Skeleton
|
|
154
127
|
const isSkeleton = node?.nodeType === "page-skeleton";
|
|
155
128
|
---
|
|
156
129
|
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import type { APIRoute } from "astro";
|
|
3
3
|
import { handleMediaProxy } from "../../lib/media/media-proxy";
|
|
4
4
|
|
|
5
|
+
export const prerender = false;
|
|
6
|
+
|
|
5
7
|
export const GET: APIRoute = async (context) => {
|
|
6
|
-
|
|
8
|
+
try {
|
|
9
|
+
return await handleMediaProxy(context);
|
|
10
|
+
} catch (error: any) {
|
|
11
|
+
console.error("❌ [Media Proxy Error]:", error?.message || error);
|
|
12
|
+
return new Response("Media Proxy Failed", { status: 500 });
|
|
13
|
+
}
|
|
7
14
|
};
|
package/wrangler.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
3
|
+
"name": "kama",
|
|
4
|
+
"main": "server/index.ts",
|
|
5
|
+
"compatibility_date": "2024-09-23",
|
|
6
|
+
"compatibility_flags": [
|
|
7
|
+
"nodejs_compat"
|
|
8
|
+
],
|
|
9
|
+
"d1_databases": [
|
|
10
|
+
{
|
|
11
|
+
"binding": "DB",
|
|
12
|
+
"database_name": "kama-db",
|
|
13
|
+
"database_id": "local-kama-db"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"r2_buckets": [
|
|
17
|
+
{
|
|
18
|
+
"binding": "MEDIA_BUCKET",
|
|
19
|
+
"bucket_name": "kama-media"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|