@btst/stack 3.0.2 → 3.1.0-rc.1
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/dist/context/index.d.cts +3 -1
- package/dist/context/index.d.mts +3 -1
- package/dist/context/index.d.ts +3 -1
- package/dist/packages/stack/src/context/auth.cjs +20 -14
- package/dist/packages/stack/src/context/auth.mjs +20 -14
- package/dist/packages/stack/src/context/provider.cjs +42 -22
- package/dist/packages/stack/src/context/provider.mjs +43 -23
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +32 -28
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +32 -29
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +53 -47
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +53 -48
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +30 -24
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +30 -25
- package/dist/plugins/blog/client/components/index.d.cts +6 -10
- package/dist/plugins/blog/client/components/index.d.mts +6 -10
- package/dist/plugins/blog/client/components/index.d.ts +6 -10
- package/dist/plugins/blog/client/pages/post.cjs +9 -0
- package/dist/plugins/blog/client/pages/post.d.cts +8 -0
- package/dist/plugins/blog/client/pages/post.d.mts +8 -0
- package/dist/plugins/blog/client/pages/post.d.ts +8 -0
- package/dist/plugins/blog/client/pages/post.mjs +7 -0
- package/dist/plugins/blog/client/pages/posts.cjs +9 -0
- package/dist/plugins/blog/client/pages/posts.d.cts +8 -0
- package/dist/plugins/blog/client/pages/posts.d.mts +8 -0
- package/dist/plugins/blog/client/pages/posts.d.ts +8 -0
- package/dist/plugins/blog/client/pages/posts.mjs +7 -0
- package/dist/plugins/blog/client/pages/tag.cjs +9 -0
- package/dist/plugins/blog/client/pages/tag.d.cts +8 -0
- package/dist/plugins/blog/client/pages/tag.d.mts +8 -0
- package/dist/plugins/blog/client/pages/tag.d.ts +8 -0
- package/dist/plugins/blog/client/pages/tag.mjs +7 -0
- package/dist/plugins/form-builder/api/index.d.cts +1 -1
- package/dist/plugins/form-builder/api/index.d.mts +1 -1
- package/dist/plugins/form-builder/api/index.d.ts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
- package/dist/plugins/form-builder/query-keys.d.cts +1 -1
- package/dist/plugins/form-builder/query-keys.d.mts +1 -1
- package/dist/plugins/form-builder/query-keys.d.ts +1 -1
- package/package.json +41 -2
- package/src/__tests__/provider-hydration.test.tsx +164 -0
- package/src/context/auth.tsx +21 -14
- package/src/context/provider.tsx +51 -28
- package/src/plugins/blog/__tests__/page-load-error.test.tsx +53 -0
- package/src/plugins/blog/__tests__/page-loading.test.tsx +106 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +39 -35
- package/src/plugins/blog/client/components/pages/post-page.tsx +62 -54
- package/src/plugins/blog/client/components/pages/tag-page.tsx +35 -29
- package/src/plugins/blog/client/pages/post.tsx +7 -0
- package/src/plugins/blog/client/pages/posts.tsx +7 -0
- package/src/plugins/blog/client/pages/tag.tsx +7 -0
- package/dist/shared/{stack.D20bOqfr.d.ts → stack.BuxUQqL8.d.ts} +20 -20
- package/dist/shared/{stack.AWSs6TXN.d.cts → stack.CX83YNuS.d.cts} +20 -20
- package/dist/shared/{stack.HB5uGLpE.d.mts → stack.Egr3RWhA.d.mts} +20 -20
package/dist/context/index.d.cts
CHANGED
|
@@ -123,6 +123,8 @@ type StackProviderServices = {
|
|
|
123
123
|
notify?: StackNotifyProvider;
|
|
124
124
|
i18n?: StackI18nProvider;
|
|
125
125
|
};
|
|
126
|
+
/** Plugin override configuration inferred from a resolved client stack. */
|
|
127
|
+
type ClientStackOverrides<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<RegisteredClientPlugins<TStack>>;
|
|
126
128
|
type CanonicalStackProviderOverrideProps<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<NoInfer<RegisteredClientPlugins<TStack>>> extends infer TOverrides extends Record<string, any> ? {} extends TOverrides ? {
|
|
127
129
|
overrides?: TOverrides;
|
|
128
130
|
} : {
|
|
@@ -339,4 +341,4 @@ type TranslateFn = (key: string, defaultValue: string, params?: Record<string, u
|
|
|
339
341
|
declare function useTranslate(): TranslateFn;
|
|
340
342
|
|
|
341
343
|
export { PermissionAccess, PermissionCheck, StackApiConfig, StackClientAuth, StackIdentity, StackProvider, StackRouter, StackRouterConfig, defaultNotifyProvider, useBasePath, useIdentity, useIdentityResolutionPromise, useIdentitySourceGeneration, useNotify, usePluginOverrides, usePluginSiteNavigation, useStack, useStackOrNull, useTranslate };
|
|
342
|
-
export type { NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
|
344
|
+
export type { ClientStackOverrides, NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -123,6 +123,8 @@ type StackProviderServices = {
|
|
|
123
123
|
notify?: StackNotifyProvider;
|
|
124
124
|
i18n?: StackI18nProvider;
|
|
125
125
|
};
|
|
126
|
+
/** Plugin override configuration inferred from a resolved client stack. */
|
|
127
|
+
type ClientStackOverrides<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<RegisteredClientPlugins<TStack>>;
|
|
126
128
|
type CanonicalStackProviderOverrideProps<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<NoInfer<RegisteredClientPlugins<TStack>>> extends infer TOverrides extends Record<string, any> ? {} extends TOverrides ? {
|
|
127
129
|
overrides?: TOverrides;
|
|
128
130
|
} : {
|
|
@@ -339,4 +341,4 @@ type TranslateFn = (key: string, defaultValue: string, params?: Record<string, u
|
|
|
339
341
|
declare function useTranslate(): TranslateFn;
|
|
340
342
|
|
|
341
343
|
export { PermissionAccess, PermissionCheck, StackApiConfig, StackClientAuth, StackIdentity, StackProvider, StackRouter, StackRouterConfig, defaultNotifyProvider, useBasePath, useIdentity, useIdentityResolutionPromise, useIdentitySourceGeneration, useNotify, usePluginOverrides, usePluginSiteNavigation, useStack, useStackOrNull, useTranslate };
|
|
342
|
-
export type { NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
|
344
|
+
export type { ClientStackOverrides, NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
package/dist/context/index.d.ts
CHANGED
|
@@ -123,6 +123,8 @@ type StackProviderServices = {
|
|
|
123
123
|
notify?: StackNotifyProvider;
|
|
124
124
|
i18n?: StackI18nProvider;
|
|
125
125
|
};
|
|
126
|
+
/** Plugin override configuration inferred from a resolved client stack. */
|
|
127
|
+
type ClientStackOverrides<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<RegisteredClientPlugins<TStack>>;
|
|
126
128
|
type CanonicalStackProviderOverrideProps<TStack extends ResolvedClientStack<any, any>> = InferredPluginOverrides<NoInfer<RegisteredClientPlugins<TStack>>> extends infer TOverrides extends Record<string, any> ? {} extends TOverrides ? {
|
|
127
129
|
overrides?: TOverrides;
|
|
128
130
|
} : {
|
|
@@ -339,4 +341,4 @@ type TranslateFn = (key: string, defaultValue: string, params?: Record<string, u
|
|
|
339
341
|
declare function useTranslate(): TranslateFn;
|
|
340
342
|
|
|
341
343
|
export { PermissionAccess, PermissionCheck, StackApiConfig, StackClientAuth, StackIdentity, StackProvider, StackRouter, StackRouterConfig, defaultNotifyProvider, useBasePath, useIdentity, useIdentityResolutionPromise, useIdentitySourceGeneration, useNotify, usePluginOverrides, usePluginSiteNavigation, useStack, useStackOrNull, useTranslate };
|
|
342
|
-
export type { NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
|
344
|
+
export type { ClientStackOverrides, NotifyOptions, PermissionCheckState, StackI18nProvider, StackNotifyProvider, TranslateFn };
|
|
@@ -119,21 +119,27 @@ function StackAuthBoundary({
|
|
|
119
119
|
if (initialIdentity !== void 0) return;
|
|
120
120
|
void resolveIdentity(false);
|
|
121
121
|
}, [initialIdentity, resolveIdentity]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
const value = React.useMemo(
|
|
123
|
+
() => ({
|
|
124
|
+
provider,
|
|
125
|
+
identity: currentState.identity,
|
|
126
|
+
isPending: currentState.isPending,
|
|
127
|
+
sourceGeneration: currentResolutionGeneration,
|
|
128
|
+
...currentState.error ? { error: currentState.error } : {},
|
|
129
|
+
refetch,
|
|
130
|
+
waitForResolution
|
|
131
|
+
}),
|
|
132
|
+
[
|
|
133
|
+
provider,
|
|
134
|
+
currentState.identity,
|
|
135
|
+
currentState.isPending,
|
|
136
|
+
currentResolutionGeneration,
|
|
137
|
+
currentState.error,
|
|
138
|
+
refetch,
|
|
139
|
+
waitForResolution
|
|
140
|
+
]
|
|
136
141
|
);
|
|
142
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
|
|
137
143
|
}
|
|
138
144
|
function useAuthContext() {
|
|
139
145
|
return React.useContext(AuthContext);
|
|
@@ -117,21 +117,27 @@ function StackAuthBoundary({
|
|
|
117
117
|
if (initialIdentity !== void 0) return;
|
|
118
118
|
void resolveIdentity(false);
|
|
119
119
|
}, [initialIdentity, resolveIdentity]);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
120
|
+
const value = useMemo(
|
|
121
|
+
() => ({
|
|
122
|
+
provider,
|
|
123
|
+
identity: currentState.identity,
|
|
124
|
+
isPending: currentState.isPending,
|
|
125
|
+
sourceGeneration: currentResolutionGeneration,
|
|
126
|
+
...currentState.error ? { error: currentState.error } : {},
|
|
127
|
+
refetch,
|
|
128
|
+
waitForResolution
|
|
129
|
+
}),
|
|
130
|
+
[
|
|
131
|
+
provider,
|
|
132
|
+
currentState.identity,
|
|
133
|
+
currentState.isPending,
|
|
134
|
+
currentResolutionGeneration,
|
|
135
|
+
currentState.error,
|
|
136
|
+
refetch,
|
|
137
|
+
waitForResolution
|
|
138
|
+
]
|
|
134
139
|
);
|
|
140
|
+
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|
|
135
141
|
}
|
|
136
142
|
function useAuthContext() {
|
|
137
143
|
return useContext(AuthContext);
|
|
@@ -17,10 +17,20 @@ function stripUndefined(obj) {
|
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
return
|
|
20
|
+
function useStaticRouter(router) {
|
|
21
|
+
const { Link, Image, navigate, refresh, getSearchParams, setSearchParams } = router ?? {};
|
|
22
|
+
const present = router !== void 0;
|
|
23
|
+
return React.useMemo(
|
|
24
|
+
() => present ? stripUndefined({
|
|
25
|
+
Link,
|
|
26
|
+
Image,
|
|
27
|
+
navigate,
|
|
28
|
+
refresh,
|
|
29
|
+
getSearchParams,
|
|
30
|
+
setSearchParams
|
|
31
|
+
}) : void 0,
|
|
32
|
+
[present, Link, Image, navigate, refresh, getSearchParams, setSearchParams]
|
|
33
|
+
);
|
|
24
34
|
}
|
|
25
35
|
function RouterBridge({
|
|
26
36
|
useRouter,
|
|
@@ -29,11 +39,14 @@ function RouterBridge({
|
|
|
29
39
|
children
|
|
30
40
|
}) {
|
|
31
41
|
const hookRouter = useRouter();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
const context = React.useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
...value,
|
|
45
|
+
router: { ...staticRouter, ...stripUndefined(hookRouter) }
|
|
46
|
+
}),
|
|
47
|
+
[value, staticRouter, hookRouter]
|
|
48
|
+
);
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackContext.Provider, { value: context, children });
|
|
37
50
|
}
|
|
38
51
|
function StackProvider({
|
|
39
52
|
children,
|
|
@@ -46,18 +59,25 @@ function StackProvider({
|
|
|
46
59
|
i18n: i18n$1
|
|
47
60
|
}) {
|
|
48
61
|
const projection = stack.provider;
|
|
49
|
-
const staticRouter =
|
|
50
|
-
const value =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
const staticRouter = useStaticRouter(router);
|
|
63
|
+
const value = React.useMemo(
|
|
64
|
+
() => ({
|
|
65
|
+
overrides: overrides ?? {},
|
|
66
|
+
basePath: projection.site.basePath,
|
|
67
|
+
api: projection.api,
|
|
68
|
+
site: projection.site,
|
|
69
|
+
plugins: projection.plugins,
|
|
70
|
+
queryClient: projection.queryClient,
|
|
71
|
+
clientStackContext: stack.context,
|
|
72
|
+
resolvedStack: stack,
|
|
73
|
+
auth: auth$1
|
|
74
|
+
}),
|
|
75
|
+
[overrides, stack, auth$1]
|
|
76
|
+
);
|
|
77
|
+
const context = React.useMemo(
|
|
78
|
+
() => ({ ...value, router: staticRouter }),
|
|
79
|
+
[value, staticRouter]
|
|
80
|
+
);
|
|
61
81
|
const content = auth$1 ? /* @__PURE__ */ jsxRuntime.jsx(auth.StackAuthBoundary, { provider: auth$1, initialIdentity, children }) : children;
|
|
62
82
|
const stackTree = router?.useRouter ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
63
83
|
RouterBridge,
|
|
@@ -67,7 +87,7 @@ function StackProvider({
|
|
|
67
87
|
value,
|
|
68
88
|
children: content
|
|
69
89
|
}
|
|
70
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(StackContext.Provider, { value:
|
|
90
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(StackContext.Provider, { value: context, children: content });
|
|
71
91
|
return /* @__PURE__ */ jsxRuntime.jsx(notify.StackNotifyBoundary, { notify: notify$1, children: /* @__PURE__ */ jsxRuntime.jsx(i18n.StackI18nBoundary, { i18n: i18n$1, children: stackTree }) });
|
|
72
92
|
}
|
|
73
93
|
function useStack() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useContext } from 'react';
|
|
3
|
+
import { useMemo, createContext, useContext } from 'react';
|
|
4
4
|
import { StackAuthBoundary } from './auth.mjs';
|
|
5
5
|
import { StackI18nBoundary } from './i18n.mjs';
|
|
6
6
|
import { StackNotifyBoundary } from './notify.mjs';
|
|
@@ -15,10 +15,20 @@ function stripUndefined(obj) {
|
|
|
15
15
|
}
|
|
16
16
|
return result;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
return
|
|
18
|
+
function useStaticRouter(router) {
|
|
19
|
+
const { Link, Image, navigate, refresh, getSearchParams, setSearchParams } = router ?? {};
|
|
20
|
+
const present = router !== void 0;
|
|
21
|
+
return useMemo(
|
|
22
|
+
() => present ? stripUndefined({
|
|
23
|
+
Link,
|
|
24
|
+
Image,
|
|
25
|
+
navigate,
|
|
26
|
+
refresh,
|
|
27
|
+
getSearchParams,
|
|
28
|
+
setSearchParams
|
|
29
|
+
}) : void 0,
|
|
30
|
+
[present, Link, Image, navigate, refresh, getSearchParams, setSearchParams]
|
|
31
|
+
);
|
|
22
32
|
}
|
|
23
33
|
function RouterBridge({
|
|
24
34
|
useRouter,
|
|
@@ -27,11 +37,14 @@ function RouterBridge({
|
|
|
27
37
|
children
|
|
28
38
|
}) {
|
|
29
39
|
const hookRouter = useRouter();
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
const context = useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
...value,
|
|
43
|
+
router: { ...staticRouter, ...stripUndefined(hookRouter) }
|
|
44
|
+
}),
|
|
45
|
+
[value, staticRouter, hookRouter]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ jsx(StackContext.Provider, { value: context, children });
|
|
35
48
|
}
|
|
36
49
|
function StackProvider({
|
|
37
50
|
children,
|
|
@@ -44,18 +57,25 @@ function StackProvider({
|
|
|
44
57
|
i18n
|
|
45
58
|
}) {
|
|
46
59
|
const projection = stack.provider;
|
|
47
|
-
const staticRouter =
|
|
48
|
-
const value =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
const staticRouter = useStaticRouter(router);
|
|
61
|
+
const value = useMemo(
|
|
62
|
+
() => ({
|
|
63
|
+
overrides: overrides ?? {},
|
|
64
|
+
basePath: projection.site.basePath,
|
|
65
|
+
api: projection.api,
|
|
66
|
+
site: projection.site,
|
|
67
|
+
plugins: projection.plugins,
|
|
68
|
+
queryClient: projection.queryClient,
|
|
69
|
+
clientStackContext: stack.context,
|
|
70
|
+
resolvedStack: stack,
|
|
71
|
+
auth
|
|
72
|
+
}),
|
|
73
|
+
[overrides, stack, auth]
|
|
74
|
+
);
|
|
75
|
+
const context = useMemo(
|
|
76
|
+
() => ({ ...value, router: staticRouter }),
|
|
77
|
+
[value, staticRouter]
|
|
78
|
+
);
|
|
59
79
|
const content = auth ? /* @__PURE__ */ jsx(StackAuthBoundary, { provider: auth, initialIdentity, children }) : children;
|
|
60
80
|
const stackTree = router?.useRouter ? /* @__PURE__ */ jsx(
|
|
61
81
|
RouterBridge,
|
|
@@ -65,7 +85,7 @@ function StackProvider({
|
|
|
65
85
|
value,
|
|
66
86
|
children: content
|
|
67
87
|
}
|
|
68
|
-
) : /* @__PURE__ */ jsx(StackContext.Provider, { value:
|
|
88
|
+
) : /* @__PURE__ */ jsx(StackContext.Provider, { value: context, children: content });
|
|
69
89
|
return /* @__PURE__ */ jsx(StackNotifyBoundary, { notify, children: /* @__PURE__ */ jsx(StackI18nBoundary, { i18n, children: stackTree }) });
|
|
70
90
|
}
|
|
71
91
|
function useStack() {
|
|
@@ -11,36 +11,40 @@ const index = require('../loading/index.cjs');
|
|
|
11
11
|
const _404Page = require('./404-page.cjs');
|
|
12
12
|
const plugins_blog_permissions = require('../../../../../../../../plugins/blog/permissions.cjs');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
isSSR: typeof window === "undefined",
|
|
38
|
-
published
|
|
39
|
-
});
|
|
14
|
+
function createHomePage(HomePage) {
|
|
15
|
+
function HomePageComponent2({ published = true }) {
|
|
16
|
+
const { onRouteError } = context.usePluginOverrides(constants.BLOG_PLUGIN_ID);
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18
|
+
components.ComposedRoute,
|
|
19
|
+
{
|
|
20
|
+
path: published ? "/blog" : "/blog/drafts",
|
|
21
|
+
PageComponent: HomePage,
|
|
22
|
+
ErrorComponent: defaultError.DefaultError,
|
|
23
|
+
LoadingComponent: index.PostsLoading,
|
|
24
|
+
NotFoundComponent: _404Page.NotFoundPage,
|
|
25
|
+
permission: plugins_blog_permissions.blogPermissions.post.read({
|
|
26
|
+
scope: published ? "published" : "drafts"
|
|
27
|
+
}),
|
|
28
|
+
props: { published },
|
|
29
|
+
onError: (error) => {
|
|
30
|
+
if (onRouteError) {
|
|
31
|
+
onRouteError("posts", error, {
|
|
32
|
+
path: published ? "/blog" : "/blog/drafts",
|
|
33
|
+
isSSR: typeof window === "undefined",
|
|
34
|
+
published
|
|
35
|
+
});
|
|
36
|
+
}
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return HomePageComponent2;
|
|
44
42
|
}
|
|
43
|
+
const HomePageComponent = createHomePage(
|
|
44
|
+
React.lazy(
|
|
45
|
+
() => import('./home-page.internal.cjs').then((m) => ({ default: m.HomePage }))
|
|
46
|
+
)
|
|
47
|
+
);
|
|
45
48
|
|
|
46
49
|
exports.HomePageComponent = HomePageComponent;
|
|
50
|
+
exports.createHomePage = createHomePage;
|
|
@@ -9,36 +9,39 @@ import { PostsLoading } from '../loading/index.mjs';
|
|
|
9
9
|
import { NotFoundPage } from './404-page.mjs';
|
|
10
10
|
import { blogPermissions } from '../../../../../../../../plugins/blog/permissions.mjs';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
isSSR: typeof window === "undefined",
|
|
36
|
-
published
|
|
37
|
-
});
|
|
12
|
+
function createHomePage(HomePage) {
|
|
13
|
+
function HomePageComponent2({ published = true }) {
|
|
14
|
+
const { onRouteError } = usePluginOverrides(BLOG_PLUGIN_ID);
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
ComposedRoute,
|
|
17
|
+
{
|
|
18
|
+
path: published ? "/blog" : "/blog/drafts",
|
|
19
|
+
PageComponent: HomePage,
|
|
20
|
+
ErrorComponent: DefaultError,
|
|
21
|
+
LoadingComponent: PostsLoading,
|
|
22
|
+
NotFoundComponent: NotFoundPage,
|
|
23
|
+
permission: blogPermissions.post.read({
|
|
24
|
+
scope: published ? "published" : "drafts"
|
|
25
|
+
}),
|
|
26
|
+
props: { published },
|
|
27
|
+
onError: (error) => {
|
|
28
|
+
if (onRouteError) {
|
|
29
|
+
onRouteError("posts", error, {
|
|
30
|
+
path: published ? "/blog" : "/blog/drafts",
|
|
31
|
+
isSSR: typeof window === "undefined",
|
|
32
|
+
published
|
|
33
|
+
});
|
|
34
|
+
}
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return HomePageComponent2;
|
|
42
40
|
}
|
|
41
|
+
const HomePageComponent = createHomePage(
|
|
42
|
+
lazy(
|
|
43
|
+
() => import('./home-page.internal.mjs').then((m) => ({ default: m.HomePage }))
|
|
44
|
+
)
|
|
45
|
+
);
|
|
43
46
|
|
|
44
|
-
export { HomePageComponent };
|
|
47
|
+
export { HomePageComponent, createHomePage };
|
|
@@ -12,55 +12,61 @@ const _404Page = require('./404-page.cjs');
|
|
|
12
12
|
const blogHooks = require('../../hooks/blog-hooks.cjs');
|
|
13
13
|
const plugins_blog_permissions = require('../../../../../../../../plugins/blog/permissions.cjs');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
15
|
+
function createPostPage(PostPageContent) {
|
|
16
|
+
function AuthorizedPostPage({ slug }) {
|
|
17
|
+
const { post } = blogHooks.useSuspensePost(slug);
|
|
18
|
+
const permission = post ? plugins_blog_permissions.blogPermissions.post.read({
|
|
19
|
+
scope: "post",
|
|
20
|
+
slug: post.slug,
|
|
21
|
+
exists: true,
|
|
22
|
+
id: post.id,
|
|
23
|
+
...post.authorId ? { authorId: post.authorId } : {},
|
|
24
|
+
published: post.published
|
|
25
|
+
}) : plugins_blog_permissions.blogPermissions.post.read({
|
|
26
|
+
scope: "post",
|
|
27
|
+
slug,
|
|
28
|
+
exists: false,
|
|
29
|
+
published: false
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
components.PermissionRouteAccess,
|
|
33
|
+
{
|
|
34
|
+
permission,
|
|
35
|
+
LoadingComponent: index.PostLoading,
|
|
36
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PostPageContent, { slug })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function PostPageComponent2({ slug }) {
|
|
41
|
+
const { onRouteError } = context.usePluginOverrides(constants.BLOG_PLUGIN_ID);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
components.ComposedRoute,
|
|
44
|
+
{
|
|
45
|
+
path: `/blog/${slug}`,
|
|
46
|
+
PageComponent: AuthorizedPostPage,
|
|
47
|
+
ErrorComponent: defaultError.DefaultError,
|
|
48
|
+
LoadingComponent: index.PostLoading,
|
|
49
|
+
NotFoundComponent: _404Page.NotFoundPage,
|
|
50
|
+
props: { slug },
|
|
51
|
+
onError: (error) => {
|
|
52
|
+
if (onRouteError) {
|
|
53
|
+
onRouteError("post", error, {
|
|
54
|
+
path: `/blog/${slug}`,
|
|
55
|
+
isSSR: typeof window === "undefined",
|
|
56
|
+
slug
|
|
57
|
+
});
|
|
58
|
+
}
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return PostPageComponent2;
|
|
64
64
|
}
|
|
65
|
+
const PostPageComponent = createPostPage(
|
|
66
|
+
React.lazy(
|
|
67
|
+
() => import('./post-page.internal.cjs').then((m) => ({ default: m.PostPage }))
|
|
68
|
+
)
|
|
69
|
+
);
|
|
65
70
|
|
|
66
71
|
exports.PostPageComponent = PostPageComponent;
|
|
72
|
+
exports.createPostPage = createPostPage;
|