astro-tractstack 2.0.0-rc.20 → 2.0.0-rc.22
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/package.json +1 -1
- package/templates/custom/minimal/CustomRoutes.astro +26 -26
- package/templates/custom/with-examples/CustomRoutes.astro +4 -4
- package/templates/custom/with-examples/pages/Collections.astro +58 -98
- package/templates/src/components/compositor/nodes/Pane.tsx +12 -5
- package/templates/src/pages/[...slug].astro +7 -2
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
---
|
|
2
|
+
//import Collections from './pages/Collections.astro';
|
|
3
|
+
import type { ResourceNode } from '@/types/compositorTypes';
|
|
4
|
+
|
|
2
5
|
export interface Props {
|
|
3
6
|
route: string;
|
|
4
7
|
slug: string;
|
|
5
|
-
resources:
|
|
8
|
+
resources: ResourceNode[];
|
|
6
9
|
variation?: string;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
|
-
const { route, slug
|
|
12
|
+
const { route, slug /*, resources */ } = Astro.props;
|
|
10
13
|
|
|
11
|
-
//
|
|
12
|
-
export const routes = {
|
|
13
|
-
// collections: true, // Uncomment to enable collections route
|
|
14
|
-
};
|
|
14
|
+
// list all here !
|
|
15
|
+
export const routes = {};
|
|
15
16
|
---
|
|
16
17
|
|
|
17
18
|
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Uncomment and customize routes as needed:
|
|
21
|
-
|
|
22
|
-
route === "collections" ? (
|
|
19
|
+
/*
|
|
20
|
+
route === 'collections' ? (
|
|
23
21
|
<Collections route={route} slug={slug} resources={payload} />
|
|
24
|
-
) :
|
|
22
|
+
) : (
|
|
25
23
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
<div class="rounded-lg bg-gray-50 p-8 text-center">
|
|
27
|
+
<p class="text-gray-600">Custom route "{route}" not found</p>
|
|
28
|
+
<p class="mt-2 text-sm text-gray-500">Available routes: collections</p>
|
|
29
|
+
<div class="mt-4 rounded border bg-white p-4 text-left text-xs">
|
|
30
|
+
<p class="mb-2 font-bold">Route Data:</p>
|
|
31
|
+
<p>Route: {route}</p>
|
|
32
|
+
<p>Slug: {slug}</p>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
/*
|
|
38
|
+
) }
|
|
39
|
+
*/
|
|
40
40
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Collections from './pages/Collections.astro';
|
|
3
|
+
import type { ResourceNode } from '@/types/compositorTypes';
|
|
3
4
|
|
|
4
5
|
export interface Props {
|
|
5
6
|
route: string;
|
|
6
7
|
slug: string;
|
|
7
|
-
resources:
|
|
8
|
+
resources: ResourceNode[];
|
|
8
9
|
variation?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const { route, slug, resources } = Astro.props;
|
|
12
13
|
|
|
14
|
+
// list all here !
|
|
13
15
|
export const routes = {
|
|
14
16
|
collections: true,
|
|
15
17
|
};
|
|
16
|
-
|
|
17
|
-
const payload = resources;
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
{
|
|
21
21
|
route === 'collections' ? (
|
|
22
|
-
<Collections route={route} slug={slug} resources={
|
|
22
|
+
<Collections route={route} slug={slug} resources={resources} />
|
|
23
23
|
) : (
|
|
24
24
|
<div class="rounded-lg bg-gray-50 p-8 text-center">
|
|
25
25
|
<p class="text-gray-600">Custom route "{route}" not found</p>
|
|
@@ -1,110 +1,70 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import CustomRoutes, { routes } from '@/custom/CustomRoutes.astro';
|
|
3
|
+
import { preHealthCheck } from '@/utils/backend';
|
|
4
|
+
//import type { ResourceNode } from '@/types/compositorTypes';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const tenantId =
|
|
7
|
+
Astro.locals.tenant?.id || import.meta.env.PUBLIC_TENANTID || 'default';
|
|
8
|
+
|
|
9
|
+
const healthCheckRedirect = await preHealthCheck(tenantId);
|
|
10
|
+
if (healthCheckRedirect !== undefined) {
|
|
11
|
+
return healthCheckRedirect;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
const {
|
|
14
|
+
const { param1 } = Astro.params;
|
|
15
|
+
// this needs to match the url path
|
|
16
|
+
const route = `collections`;
|
|
13
17
|
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// if (menuResponse.ok) {
|
|
22
|
-
// menuPayload = await menuResponse.json();
|
|
23
|
-
// }
|
|
24
|
-
//} catch (error) {
|
|
25
|
-
// console.error('Error fetching menu:', error);
|
|
26
|
-
//}
|
|
18
|
+
// Check if route is enabled
|
|
19
|
+
if (!param1 || !routes[route]) {
|
|
20
|
+
return new Response(null, {
|
|
21
|
+
status: 404,
|
|
22
|
+
statusText: 'Not Found',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const activeResource = categoryResources.find(
|
|
31
|
-
(resource: any) => resource.slug === targetSlug
|
|
32
|
-
);
|
|
26
|
+
// include all resource categories here
|
|
27
|
+
const CATEGORIES = [`collections`];
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
let resources = [];
|
|
30
|
+
const goBackend = import.meta.env.PUBLIC_GO_BACKEND || 'http://localhost:8080';
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</div>
|
|
32
|
+
try {
|
|
33
|
+
const resourcesResponse = await fetch(`${goBackend}/api/v1/nodes/resources`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: { 'Content-Type': 'application/json', 'X-Tenant-ID': tenantId },
|
|
36
|
+
body: JSON.stringify({ categories: CATEGORIES }),
|
|
37
|
+
});
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
if (resourcesResponse.ok) {
|
|
40
|
+
const responseData = await resourcesResponse.json();
|
|
41
|
+
if (responseData.resources) {
|
|
42
|
+
resources = responseData.resources;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error fetching resources:', error);
|
|
47
|
+
return new Response(null, {
|
|
48
|
+
status: 500,
|
|
49
|
+
statusText: 'Internal Server Error',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<p>Slug: {activeResource.slug}</p>
|
|
63
|
-
<p>Category: {activeResource.categorySlug || 'none'}</p>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
) : (
|
|
67
|
-
<div class="mb-6 rounded-lg bg-yellow-50 p-6">
|
|
68
|
-
<p class="text-yellow-800">
|
|
69
|
-
No active resource found for slug: {targetSlug}
|
|
70
|
-
</p>
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
53
|
+
/*
|
|
54
|
+
if (!resources.length) {
|
|
55
|
+
return new Response(null, {
|
|
56
|
+
status: 404,
|
|
57
|
+
statusText: 'Not Found',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
*/
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
All Resources in Category ({categoryResources.length})
|
|
77
|
-
</h3>
|
|
78
|
-
{categoryResources.length > 0 ? (
|
|
79
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
80
|
-
{categoryResources.map((resource: any) => (
|
|
81
|
-
<div class="rounded border bg-white p-4">
|
|
82
|
-
<h4 class="font-bold text-gray-900">{resource.title}</h4>
|
|
83
|
-
<p class="mt-1 text-sm text-gray-600">
|
|
84
|
-
{resource.oneliner}
|
|
85
|
-
</p>
|
|
86
|
-
<div class="mt-2 text-xs text-gray-500">
|
|
87
|
-
<p>Slug: {resource.slug}</p>
|
|
88
|
-
{resource.categorySlug && (
|
|
89
|
-
<p>Category: {resource.categorySlug}</p>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
))}
|
|
94
|
-
</div>
|
|
95
|
-
) : (
|
|
96
|
-
<p class="text-gray-500">
|
|
97
|
-
No resources found in this category.
|
|
98
|
-
</p>
|
|
99
|
-
)}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
) : null
|
|
103
|
-
}
|
|
104
|
-
</div>
|
|
105
|
-
</main>
|
|
62
|
+
const pageTitle = `${route} collection`;
|
|
63
|
+
---
|
|
106
64
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
65
|
+
<div class="border-b bg-gray-100 p-4">
|
|
66
|
+
<h1 class="text-2xl font-bold">{pageTitle}</h1>
|
|
67
|
+
<p class="text-sm text-gray-600">
|
|
68
|
+
Collections page - slug: {param1}
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
@@ -27,12 +27,19 @@ const CodeHookContainer = ({
|
|
|
27
27
|
{Object.entries(payload.params).map(
|
|
28
28
|
([key, value]) =>
|
|
29
29
|
value && (
|
|
30
|
-
|
|
30
|
+
<>
|
|
31
31
|
<span className="min-w-24 font-bold text-gray-600">{key}:</span>
|
|
32
|
-
<
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
<div className="ml-2 flex flex-wrap gap-1">
|
|
33
|
+
{value.split('|').map((item, index) => (
|
|
34
|
+
<span
|
|
35
|
+
key={index}
|
|
36
|
+
className="inline-block rounded bg-gray-200 px-2 py-0.5 text-xs text-gray-800"
|
|
37
|
+
>
|
|
38
|
+
{item}
|
|
39
|
+
</span>
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
</>
|
|
36
43
|
)
|
|
37
44
|
)}
|
|
38
45
|
</div>
|
|
@@ -133,10 +133,15 @@ if (!brandConfig.SITE_INIT) {
|
|
|
133
133
|
<div class="overflow-hidden">
|
|
134
134
|
<CodeHook
|
|
135
135
|
target={codeHookTargets[paneId]}
|
|
136
|
-
|
|
136
|
+
options={(() => {
|
|
137
|
+
const optionsStr =
|
|
138
|
+
codeHookTargets[paneId + '-' + codeHookTargets[paneId]];
|
|
139
|
+
return optionsStr
|
|
140
|
+
? { params: { options: optionsStr } }
|
|
141
|
+
: undefined;
|
|
142
|
+
})()}
|
|
137
143
|
fullContentMap={fullContentMap}
|
|
138
144
|
resourcesPayload={resourcesPayload}
|
|
139
|
-
noPaneId={true}
|
|
140
145
|
/>
|
|
141
146
|
</div>
|
|
142
147
|
) : (
|