@btst/stack 1.1.8 → 1.1.10
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/packages/better-stack/src/plugins/blog/client/plugin.cjs +12 -8
- package/dist/packages/better-stack/src/plugins/blog/client/plugin.mjs +12 -8
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +3 -2
- package/dist/plugins/blog/client/index.d.mts +3 -2
- package/dist/plugins/blog/client/index.d.ts +3 -2
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/package.json +1 -1
- package/src/plugins/blog/client/plugin.tsx +14 -5
- package/dist/shared/{stack.CoPoHVfV.d.cts → stack.Cr2JoQdo.d.cts} +1 -1
- package/dist/shared/{stack.CoPoHVfV.d.mts → stack.Cr2JoQdo.d.mts} +1 -1
- package/dist/shared/{stack.CoPoHVfV.d.ts → stack.Cr2JoQdo.d.ts} +1 -1
|
@@ -18,7 +18,8 @@ function createPostsLoader(published, config) {
|
|
|
18
18
|
path: published ? "/blog" : "/blog/drafts",
|
|
19
19
|
isSSR: true,
|
|
20
20
|
apiBaseURL,
|
|
21
|
-
apiBasePath
|
|
21
|
+
apiBasePath,
|
|
22
|
+
headers
|
|
22
23
|
};
|
|
23
24
|
try {
|
|
24
25
|
if (hooks?.beforeLoadPosts) {
|
|
@@ -70,16 +71,17 @@ function createPostsLoader(published, config) {
|
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
function createPostLoader(slug, config) {
|
|
74
|
+
function createPostLoader(slug, config, path) {
|
|
74
75
|
return async () => {
|
|
75
76
|
if (typeof window === "undefined") {
|
|
76
77
|
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
77
78
|
const context = {
|
|
78
|
-
path: `/blog/${slug}`,
|
|
79
|
+
path: path ?? `/blog/${slug}`,
|
|
79
80
|
params: { slug },
|
|
80
81
|
isSSR: true,
|
|
81
82
|
apiBaseURL,
|
|
82
|
-
apiBasePath
|
|
83
|
+
apiBasePath,
|
|
84
|
+
headers
|
|
83
85
|
};
|
|
84
86
|
try {
|
|
85
87
|
if (hooks?.beforeLoadPost) {
|
|
@@ -120,12 +122,13 @@ function createPostLoader(slug, config) {
|
|
|
120
122
|
function createNewPostLoader(config) {
|
|
121
123
|
return async () => {
|
|
122
124
|
if (typeof window === "undefined") {
|
|
123
|
-
const { apiBasePath, apiBaseURL, hooks } = config;
|
|
125
|
+
const { apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
124
126
|
const context = {
|
|
125
127
|
path: "/blog/new",
|
|
126
128
|
isSSR: true,
|
|
127
129
|
apiBaseURL,
|
|
128
|
-
apiBasePath
|
|
130
|
+
apiBasePath,
|
|
131
|
+
headers
|
|
129
132
|
};
|
|
130
133
|
try {
|
|
131
134
|
if (hooks?.beforeLoadNewPost) {
|
|
@@ -157,7 +160,8 @@ function createTagLoader(tagSlug, config) {
|
|
|
157
160
|
params: { tagSlug },
|
|
158
161
|
isSSR: true,
|
|
159
162
|
apiBaseURL,
|
|
160
|
-
apiBasePath
|
|
163
|
+
apiBasePath,
|
|
164
|
+
headers
|
|
161
165
|
};
|
|
162
166
|
try {
|
|
163
167
|
const limit = 10;
|
|
@@ -430,7 +434,7 @@ const blogClientPlugin = (config) => client.defineClientPlugin({
|
|
|
430
434
|
editPost: yar.createRoute("/blog/:slug/edit", ({ params: { slug } }) => {
|
|
431
435
|
return {
|
|
432
436
|
PageComponent: () => /* @__PURE__ */ jsxRuntime.jsx(editPostPage.EditPostPageComponent, { slug }),
|
|
433
|
-
loader: createPostLoader(slug, config),
|
|
437
|
+
loader: createPostLoader(slug, config, `/blog/${slug}/edit`),
|
|
434
438
|
meta: createEditPostMeta(slug, config)
|
|
435
439
|
};
|
|
436
440
|
}),
|
|
@@ -16,7 +16,8 @@ function createPostsLoader(published, config) {
|
|
|
16
16
|
path: published ? "/blog" : "/blog/drafts",
|
|
17
17
|
isSSR: true,
|
|
18
18
|
apiBaseURL,
|
|
19
|
-
apiBasePath
|
|
19
|
+
apiBasePath,
|
|
20
|
+
headers
|
|
20
21
|
};
|
|
21
22
|
try {
|
|
22
23
|
if (hooks?.beforeLoadPosts) {
|
|
@@ -68,16 +69,17 @@ function createPostsLoader(published, config) {
|
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
|
-
function createPostLoader(slug, config) {
|
|
72
|
+
function createPostLoader(slug, config, path) {
|
|
72
73
|
return async () => {
|
|
73
74
|
if (typeof window === "undefined") {
|
|
74
75
|
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
75
76
|
const context = {
|
|
76
|
-
path: `/blog/${slug}`,
|
|
77
|
+
path: path ?? `/blog/${slug}`,
|
|
77
78
|
params: { slug },
|
|
78
79
|
isSSR: true,
|
|
79
80
|
apiBaseURL,
|
|
80
|
-
apiBasePath
|
|
81
|
+
apiBasePath,
|
|
82
|
+
headers
|
|
81
83
|
};
|
|
82
84
|
try {
|
|
83
85
|
if (hooks?.beforeLoadPost) {
|
|
@@ -118,12 +120,13 @@ function createPostLoader(slug, config) {
|
|
|
118
120
|
function createNewPostLoader(config) {
|
|
119
121
|
return async () => {
|
|
120
122
|
if (typeof window === "undefined") {
|
|
121
|
-
const { apiBasePath, apiBaseURL, hooks } = config;
|
|
123
|
+
const { apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
122
124
|
const context = {
|
|
123
125
|
path: "/blog/new",
|
|
124
126
|
isSSR: true,
|
|
125
127
|
apiBaseURL,
|
|
126
|
-
apiBasePath
|
|
128
|
+
apiBasePath,
|
|
129
|
+
headers
|
|
127
130
|
};
|
|
128
131
|
try {
|
|
129
132
|
if (hooks?.beforeLoadNewPost) {
|
|
@@ -155,7 +158,8 @@ function createTagLoader(tagSlug, config) {
|
|
|
155
158
|
params: { tagSlug },
|
|
156
159
|
isSSR: true,
|
|
157
160
|
apiBaseURL,
|
|
158
|
-
apiBasePath
|
|
161
|
+
apiBasePath,
|
|
162
|
+
headers
|
|
159
163
|
};
|
|
160
164
|
try {
|
|
161
165
|
const limit = 10;
|
|
@@ -428,7 +432,7 @@ const blogClientPlugin = (config) => defineClientPlugin({
|
|
|
428
432
|
editPost: createRoute("/blog/:slug/edit", ({ params: { slug } }) => {
|
|
429
433
|
return {
|
|
430
434
|
PageComponent: () => /* @__PURE__ */ jsx(EditPostPageComponent, { slug }),
|
|
431
|
-
loader: createPostLoader(slug, config),
|
|
435
|
+
loader: createPostLoader(slug, config, `/blog/${slug}/edit`),
|
|
432
436
|
meta: createEditPostMeta(slug, config)
|
|
433
437
|
};
|
|
434
438
|
}),
|
|
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
|
|
|
2
2
|
import '@btst/stack/plugins/api';
|
|
3
3
|
import 'better-call';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../../../shared/stack.
|
|
5
|
+
import '../../../shared/stack.Cr2JoQdo.cjs';
|
|
6
6
|
import '@tanstack/react-query';
|
|
7
7
|
import '@btst/stack/plugins/client';
|
|
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
|
|
|
2
2
|
import '@btst/stack/plugins/api';
|
|
3
3
|
import 'better-call';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../../../shared/stack.
|
|
5
|
+
import '../../../shared/stack.Cr2JoQdo.mjs';
|
|
6
6
|
import '@tanstack/react-query';
|
|
7
7
|
import '@btst/stack/plugins/client';
|
|
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
|
|
|
2
2
|
import '@btst/stack/plugins/api';
|
|
3
3
|
import 'better-call';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import '../../../shared/stack.
|
|
5
|
+
import '../../../shared/stack.Cr2JoQdo.js';
|
|
6
6
|
import '@tanstack/react-query';
|
|
7
7
|
import '@btst/stack/plugins/client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.
|
|
2
|
+
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.Cr2JoQdo.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
interface UsePostsOptions {
|
|
@@ -81,8 +81,8 @@ declare function useSuspenseTags(): {
|
|
|
81
81
|
};
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
|
-
published: boolean;
|
|
85
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
86
86
|
content: string;
|
|
87
87
|
excerpt: string;
|
|
88
88
|
tags: ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.
|
|
2
|
+
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.Cr2JoQdo.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
interface UsePostsOptions {
|
|
@@ -81,8 +81,8 @@ declare function useSuspenseTags(): {
|
|
|
81
81
|
};
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
|
-
published: boolean;
|
|
85
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
86
86
|
content: string;
|
|
87
87
|
excerpt: string;
|
|
88
88
|
tags: ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.
|
|
2
|
+
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.Cr2JoQdo.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
interface UsePostsOptions {
|
|
@@ -81,8 +81,8 @@ declare function useSuspenseTags(): {
|
|
|
81
81
|
};
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
|
-
published: boolean;
|
|
85
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
86
86
|
content: string;
|
|
87
87
|
excerpt: string;
|
|
88
88
|
tags: ({
|
|
@@ -3,7 +3,7 @@ import * as react from 'react';
|
|
|
3
3
|
import { ComponentType } from 'react';
|
|
4
4
|
import * as _btst_yar from '@btst/yar';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
import { P as Post, S as SerializedPost } from '../../../shared/stack.
|
|
6
|
+
import { P as Post, S as SerializedPost } from '../../../shared/stack.Cr2JoQdo.cjs';
|
|
7
7
|
export { UsePostsOptions, UsePostsResult } from './hooks/index.cjs';
|
|
8
8
|
import 'zod';
|
|
9
9
|
|
|
@@ -25,6 +25,7 @@ interface LoaderContext {
|
|
|
25
25
|
isSSR: boolean;
|
|
26
26
|
apiBaseURL: string;
|
|
27
27
|
apiBasePath: string;
|
|
28
|
+
headers?: Headers;
|
|
28
29
|
[key: string]: any;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -45,7 +46,7 @@ interface BlogClientConfig {
|
|
|
45
46
|
defaultImage?: string;
|
|
46
47
|
};
|
|
47
48
|
hooks?: BlogClientHooks;
|
|
48
|
-
headers?:
|
|
49
|
+
headers?: Headers;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Hooks for blog client plugin
|
|
@@ -3,7 +3,7 @@ import * as react from 'react';
|
|
|
3
3
|
import { ComponentType } from 'react';
|
|
4
4
|
import * as _btst_yar from '@btst/yar';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
import { P as Post, S as SerializedPost } from '../../../shared/stack.
|
|
6
|
+
import { P as Post, S as SerializedPost } from '../../../shared/stack.Cr2JoQdo.mjs';
|
|
7
7
|
export { UsePostsOptions, UsePostsResult } from './hooks/index.mjs';
|
|
8
8
|
import 'zod';
|
|
9
9
|
|
|
@@ -25,6 +25,7 @@ interface LoaderContext {
|
|
|
25
25
|
isSSR: boolean;
|
|
26
26
|
apiBaseURL: string;
|
|
27
27
|
apiBasePath: string;
|
|
28
|
+
headers?: Headers;
|
|
28
29
|
[key: string]: any;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -45,7 +46,7 @@ interface BlogClientConfig {
|
|
|
45
46
|
defaultImage?: string;
|
|
46
47
|
};
|
|
47
48
|
hooks?: BlogClientHooks;
|
|
48
|
-
headers?:
|
|
49
|
+
headers?: Headers;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Hooks for blog client plugin
|
|
@@ -3,7 +3,7 @@ import * as react from 'react';
|
|
|
3
3
|
import { ComponentType } from 'react';
|
|
4
4
|
import * as _btst_yar from '@btst/yar';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
import { P as Post, S as SerializedPost } from '../../../shared/stack.
|
|
6
|
+
import { P as Post, S as SerializedPost } from '../../../shared/stack.Cr2JoQdo.js';
|
|
7
7
|
export { UsePostsOptions, UsePostsResult } from './hooks/index.js';
|
|
8
8
|
import 'zod';
|
|
9
9
|
|
|
@@ -25,6 +25,7 @@ interface LoaderContext {
|
|
|
25
25
|
isSSR: boolean;
|
|
26
26
|
apiBaseURL: string;
|
|
27
27
|
apiBasePath: string;
|
|
28
|
+
headers?: Headers;
|
|
28
29
|
[key: string]: any;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
@@ -45,7 +46,7 @@ interface BlogClientConfig {
|
|
|
45
46
|
defaultImage?: string;
|
|
46
47
|
};
|
|
47
48
|
hooks?: BlogClientHooks;
|
|
48
|
-
headers?:
|
|
49
|
+
headers?: Headers;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Hooks for blog client plugin
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.
|
|
4
|
+
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.Cr2JoQdo.cjs';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
7
7
|
|
|
@@ -173,12 +173,12 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
173
173
|
options: {
|
|
174
174
|
method: "POST";
|
|
175
175
|
body: z.ZodObject<{
|
|
176
|
+
title: z.ZodString;
|
|
176
177
|
slug: z.ZodOptional<z.ZodString>;
|
|
177
178
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
178
179
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
180
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
181
|
-
title: z.ZodString;
|
|
182
182
|
content: z.ZodString;
|
|
183
183
|
excerpt: z.ZodString;
|
|
184
184
|
image: z.ZodOptional<z.ZodString>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.
|
|
4
|
+
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.Cr2JoQdo.mjs';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
7
7
|
|
|
@@ -173,12 +173,12 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
173
173
|
options: {
|
|
174
174
|
method: "POST";
|
|
175
175
|
body: z.ZodObject<{
|
|
176
|
+
title: z.ZodString;
|
|
176
177
|
slug: z.ZodOptional<z.ZodString>;
|
|
177
178
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
178
179
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
180
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
181
|
-
title: z.ZodString;
|
|
182
182
|
content: z.ZodString;
|
|
183
183
|
excerpt: z.ZodString;
|
|
184
184
|
image: z.ZodOptional<z.ZodString>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
2
|
import * as better_call from 'better-call';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.
|
|
4
|
+
import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.Cr2JoQdo.js';
|
|
5
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
6
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
7
7
|
|
|
@@ -173,12 +173,12 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
173
173
|
options: {
|
|
174
174
|
method: "POST";
|
|
175
175
|
body: z.ZodObject<{
|
|
176
|
+
title: z.ZodString;
|
|
176
177
|
slug: z.ZodOptional<z.ZodString>;
|
|
177
178
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
178
179
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
180
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
181
|
-
title: z.ZodString;
|
|
182
182
|
content: z.ZodString;
|
|
183
183
|
excerpt: z.ZodString;
|
|
184
184
|
image: z.ZodOptional<z.ZodString>;
|
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@ export interface LoaderContext {
|
|
|
32
32
|
isSSR: boolean;
|
|
33
33
|
apiBaseURL: string;
|
|
34
34
|
apiBasePath: string;
|
|
35
|
+
headers?: Headers;
|
|
35
36
|
[key: string]: any;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -60,7 +61,7 @@ export interface BlogClientConfig {
|
|
|
60
61
|
hooks?: BlogClientHooks;
|
|
61
62
|
|
|
62
63
|
// Optional headers for SSR (e.g., forwarding cookies)
|
|
63
|
-
headers?:
|
|
64
|
+
headers?: Headers;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -103,6 +104,7 @@ function createPostsLoader(published: boolean, config: BlogClientConfig) {
|
|
|
103
104
|
isSSR: true,
|
|
104
105
|
apiBaseURL,
|
|
105
106
|
apiBasePath,
|
|
107
|
+
headers,
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
try {
|
|
@@ -179,17 +181,22 @@ function createPostsLoader(published: boolean, config: BlogClientConfig) {
|
|
|
179
181
|
};
|
|
180
182
|
}
|
|
181
183
|
|
|
182
|
-
function createPostLoader(
|
|
184
|
+
function createPostLoader(
|
|
185
|
+
slug: string,
|
|
186
|
+
config: BlogClientConfig,
|
|
187
|
+
path?: string,
|
|
188
|
+
) {
|
|
183
189
|
return async () => {
|
|
184
190
|
if (typeof window === "undefined") {
|
|
185
191
|
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
186
192
|
|
|
187
193
|
const context: LoaderContext = {
|
|
188
|
-
path: `/blog/${slug}`,
|
|
194
|
+
path: path ?? `/blog/${slug}`,
|
|
189
195
|
params: { slug },
|
|
190
196
|
isSSR: true,
|
|
191
197
|
apiBaseURL,
|
|
192
198
|
apiBasePath,
|
|
199
|
+
headers,
|
|
193
200
|
};
|
|
194
201
|
|
|
195
202
|
try {
|
|
@@ -250,13 +257,14 @@ function createPostLoader(slug: string, config: BlogClientConfig) {
|
|
|
250
257
|
function createNewPostLoader(config: BlogClientConfig) {
|
|
251
258
|
return async () => {
|
|
252
259
|
if (typeof window === "undefined") {
|
|
253
|
-
const { apiBasePath, apiBaseURL, hooks } = config;
|
|
260
|
+
const { apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
254
261
|
|
|
255
262
|
const context: LoaderContext = {
|
|
256
263
|
path: "/blog/new",
|
|
257
264
|
isSSR: true,
|
|
258
265
|
apiBaseURL,
|
|
259
266
|
apiBasePath,
|
|
267
|
+
headers,
|
|
260
268
|
};
|
|
261
269
|
|
|
262
270
|
try {
|
|
@@ -298,6 +306,7 @@ function createTagLoader(tagSlug: string, config: BlogClientConfig) {
|
|
|
298
306
|
isSSR: true,
|
|
299
307
|
apiBaseURL,
|
|
300
308
|
apiBasePath,
|
|
309
|
+
headers,
|
|
301
310
|
};
|
|
302
311
|
|
|
303
312
|
try {
|
|
@@ -643,7 +652,7 @@ export const blogClientPlugin = (config: BlogClientConfig) =>
|
|
|
643
652
|
editPost: createRoute("/blog/:slug/edit", ({ params: { slug } }) => {
|
|
644
653
|
return {
|
|
645
654
|
PageComponent: () => <EditPostPageComponent slug={slug} />,
|
|
646
|
-
loader: createPostLoader(slug, config),
|
|
655
|
+
loader: createPostLoader(slug, config, `/blog/${slug}/edit`),
|
|
647
656
|
meta: createEditPostMeta(slug, config),
|
|
648
657
|
};
|
|
649
658
|
}),
|
|
@@ -35,12 +35,12 @@ interface SerializedTag extends Omit<Tag, "createdAt" | "updatedAt"> {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
declare const createPostSchema: z.ZodObject<{
|
|
38
|
+
title: z.ZodString;
|
|
38
39
|
slug: z.ZodOptional<z.ZodString>;
|
|
39
40
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
40
41
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
42
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
43
|
-
title: z.ZodString;
|
|
44
44
|
content: z.ZodString;
|
|
45
45
|
excerpt: z.ZodString;
|
|
46
46
|
image: z.ZodOptional<z.ZodString>;
|
|
@@ -35,12 +35,12 @@ interface SerializedTag extends Omit<Tag, "createdAt" | "updatedAt"> {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
declare const createPostSchema: z.ZodObject<{
|
|
38
|
+
title: z.ZodString;
|
|
38
39
|
slug: z.ZodOptional<z.ZodString>;
|
|
39
40
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
40
41
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
42
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
43
|
-
title: z.ZodString;
|
|
44
44
|
content: z.ZodString;
|
|
45
45
|
excerpt: z.ZodString;
|
|
46
46
|
image: z.ZodOptional<z.ZodString>;
|
|
@@ -35,12 +35,12 @@ interface SerializedTag extends Omit<Tag, "createdAt" | "updatedAt"> {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
declare const createPostSchema: z.ZodObject<{
|
|
38
|
+
title: z.ZodString;
|
|
38
39
|
slug: z.ZodOptional<z.ZodString>;
|
|
39
40
|
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
40
41
|
createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
42
|
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
43
|
-
title: z.ZodString;
|
|
44
44
|
content: z.ZodString;
|
|
45
45
|
excerpt: z.ZodString;
|
|
46
46
|
image: z.ZodOptional<z.ZodString>;
|