@btst/stack 1.1.6 → 1.1.7
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/hooks/blog-hooks.cjs +16 -16
- package/dist/packages/better-stack/src/plugins/blog/client/hooks/blog-hooks.mjs +16 -16
- package/dist/packages/better-stack/src/plugins/blog/client/plugin.cjs +6 -6
- package/dist/packages/better-stack/src/plugins/blog/client/plugin.mjs +6 -6
- 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 +3 -3
- package/dist/plugins/blog/client/hooks/index.d.mts +3 -3
- package/dist/plugins/blog/client/hooks/index.d.ts +3 -3
- package/dist/plugins/blog/client/index.d.cts +6 -1
- package/dist/plugins/blog/client/index.d.mts +6 -1
- package/dist/plugins/blog/client/index.d.ts +6 -1
- package/dist/plugins/blog/query-keys.cjs +19 -13
- package/dist/plugins/blog/query-keys.d.cts +7 -7
- package/dist/plugins/blog/query-keys.d.mts +7 -7
- package/dist/plugins/blog/query-keys.d.ts +7 -7
- package/dist/plugins/blog/query-keys.mjs +19 -13
- package/package.json +1 -1
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +16 -16
- package/src/plugins/blog/client/overrides.ts +4 -0
- package/src/plugins/blog/client/plugin.tsx +9 -6
- package/src/plugins/blog/query-keys.ts +13 -3
- package/dist/shared/{stack.CbuN2zVV.d.cts → stack.Cr2JoQdo.d.cts} +3 -3
- package/dist/shared/{stack.CbuN2zVV.d.mts → stack.Cr2JoQdo.d.mts} +3 -3
- package/dist/shared/{stack.CbuN2zVV.d.ts → stack.Cr2JoQdo.d.ts} +3 -3
|
@@ -20,7 +20,7 @@ const SHARED_QUERY_CONFIG = {
|
|
|
20
20
|
// 10 minutes
|
|
21
21
|
};
|
|
22
22
|
function usePosts(options = {}) {
|
|
23
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
23
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
24
24
|
const client$1 = client.createApiClient({
|
|
25
25
|
baseURL: apiBaseURL,
|
|
26
26
|
basePath: apiBasePath
|
|
@@ -33,7 +33,7 @@ function usePosts(options = {}) {
|
|
|
33
33
|
query,
|
|
34
34
|
published
|
|
35
35
|
} = options;
|
|
36
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
36
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
37
37
|
const queryParams = {
|
|
38
38
|
tag,
|
|
39
39
|
tagSlug,
|
|
@@ -73,7 +73,7 @@ function usePosts(options = {}) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
function useSuspensePosts(options = {}) {
|
|
76
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
76
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
77
77
|
const client$1 = client.createApiClient({
|
|
78
78
|
baseURL: apiBaseURL,
|
|
79
79
|
basePath: apiBasePath
|
|
@@ -86,7 +86,7 @@ function useSuspensePosts(options = {}) {
|
|
|
86
86
|
query,
|
|
87
87
|
published
|
|
88
88
|
} = options;
|
|
89
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
89
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
90
90
|
const queryParams = { tag, tagSlug, limit, query, published };
|
|
91
91
|
const basePosts = queries.posts.list(queryParams);
|
|
92
92
|
const {
|
|
@@ -120,12 +120,12 @@ function useSuspensePosts(options = {}) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
function usePost(slug) {
|
|
123
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
123
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
124
124
|
const client$1 = client.createApiClient({
|
|
125
125
|
baseURL: apiBaseURL,
|
|
126
126
|
basePath: apiBasePath
|
|
127
127
|
});
|
|
128
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
128
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
129
129
|
const basePost = queries.posts.detail(slug ?? "");
|
|
130
130
|
const { data, isLoading, error, refetch } = reactQuery.useQuery({
|
|
131
131
|
...basePost,
|
|
@@ -140,12 +140,12 @@ function usePost(slug) {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
function useSuspensePost(slug) {
|
|
143
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
143
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
144
144
|
const client$1 = client.createApiClient({
|
|
145
145
|
baseURL: apiBaseURL,
|
|
146
146
|
basePath: apiBasePath
|
|
147
147
|
});
|
|
148
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
148
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
149
149
|
const basePost = queries.posts.detail(slug);
|
|
150
150
|
const { data, refetch, error, isFetching } = reactQuery.useSuspenseQuery({
|
|
151
151
|
...basePost,
|
|
@@ -157,12 +157,12 @@ function useSuspensePost(slug) {
|
|
|
157
157
|
return { post: data || null, refetch };
|
|
158
158
|
}
|
|
159
159
|
function useTags() {
|
|
160
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
160
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
161
161
|
const client$1 = client.createApiClient({
|
|
162
162
|
baseURL: apiBaseURL,
|
|
163
163
|
basePath: apiBasePath
|
|
164
164
|
});
|
|
165
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
165
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
166
166
|
const baseTags = queries.tags.list();
|
|
167
167
|
const { data, isLoading, error, refetch } = reactQuery.useQuery({
|
|
168
168
|
...baseTags,
|
|
@@ -177,12 +177,12 @@ function useTags() {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function useSuspenseTags() {
|
|
180
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
180
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
181
181
|
const client$1 = client.createApiClient({
|
|
182
182
|
baseURL: apiBaseURL,
|
|
183
183
|
basePath: apiBasePath
|
|
184
184
|
});
|
|
185
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
185
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
186
186
|
const baseTags = queries.tags.list();
|
|
187
187
|
const { data, refetch, error, isFetching } = reactQuery.useSuspenseQuery({
|
|
188
188
|
...baseTags,
|
|
@@ -336,12 +336,12 @@ function usePostSearch({
|
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
function useNextPreviousPosts(createdAt, options = {}) {
|
|
339
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
339
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
340
340
|
const client$1 = client.createApiClient({
|
|
341
341
|
baseURL: apiBaseURL,
|
|
342
342
|
basePath: apiBasePath
|
|
343
343
|
});
|
|
344
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
344
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
345
345
|
const { ref, inView } = reactIntersectionObserver.useInView({
|
|
346
346
|
// start a little early so the data is ready as it scrolls in
|
|
347
347
|
rootMargin: "200px 0px",
|
|
@@ -366,12 +366,12 @@ function useNextPreviousPosts(createdAt, options = {}) {
|
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
368
|
function useRecentPosts(options = {}) {
|
|
369
|
-
const { apiBaseURL, apiBasePath } = context.usePluginOverrides("blog");
|
|
369
|
+
const { apiBaseURL, apiBasePath, headers } = context.usePluginOverrides("blog");
|
|
370
370
|
const client$1 = client.createApiClient({
|
|
371
371
|
baseURL: apiBaseURL,
|
|
372
372
|
basePath: apiBasePath
|
|
373
373
|
});
|
|
374
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
374
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
375
375
|
const { ref, inView } = reactIntersectionObserver.useInView({
|
|
376
376
|
// start a little early so the data is ready as it scrolls in
|
|
377
377
|
rootMargin: "200px 0px",
|
|
@@ -18,7 +18,7 @@ const SHARED_QUERY_CONFIG = {
|
|
|
18
18
|
// 10 minutes
|
|
19
19
|
};
|
|
20
20
|
function usePosts(options = {}) {
|
|
21
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
21
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
22
22
|
const client = createApiClient({
|
|
23
23
|
baseURL: apiBaseURL,
|
|
24
24
|
basePath: apiBasePath
|
|
@@ -31,7 +31,7 @@ function usePosts(options = {}) {
|
|
|
31
31
|
query,
|
|
32
32
|
published
|
|
33
33
|
} = options;
|
|
34
|
-
const queries = createBlogQueryKeys(client);
|
|
34
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
35
35
|
const queryParams = {
|
|
36
36
|
tag,
|
|
37
37
|
tagSlug,
|
|
@@ -71,7 +71,7 @@ function usePosts(options = {}) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
function useSuspensePosts(options = {}) {
|
|
74
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
74
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
75
75
|
const client = createApiClient({
|
|
76
76
|
baseURL: apiBaseURL,
|
|
77
77
|
basePath: apiBasePath
|
|
@@ -84,7 +84,7 @@ function useSuspensePosts(options = {}) {
|
|
|
84
84
|
query,
|
|
85
85
|
published
|
|
86
86
|
} = options;
|
|
87
|
-
const queries = createBlogQueryKeys(client);
|
|
87
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
88
88
|
const queryParams = { tag, tagSlug, limit, query, published };
|
|
89
89
|
const basePosts = queries.posts.list(queryParams);
|
|
90
90
|
const {
|
|
@@ -118,12 +118,12 @@ function useSuspensePosts(options = {}) {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
function usePost(slug) {
|
|
121
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
121
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
122
122
|
const client = createApiClient({
|
|
123
123
|
baseURL: apiBaseURL,
|
|
124
124
|
basePath: apiBasePath
|
|
125
125
|
});
|
|
126
|
-
const queries = createBlogQueryKeys(client);
|
|
126
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
127
127
|
const basePost = queries.posts.detail(slug ?? "");
|
|
128
128
|
const { data, isLoading, error, refetch } = useQuery({
|
|
129
129
|
...basePost,
|
|
@@ -138,12 +138,12 @@ function usePost(slug) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
function useSuspensePost(slug) {
|
|
141
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
141
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
142
142
|
const client = createApiClient({
|
|
143
143
|
baseURL: apiBaseURL,
|
|
144
144
|
basePath: apiBasePath
|
|
145
145
|
});
|
|
146
|
-
const queries = createBlogQueryKeys(client);
|
|
146
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
147
147
|
const basePost = queries.posts.detail(slug);
|
|
148
148
|
const { data, refetch, error, isFetching } = useSuspenseQuery({
|
|
149
149
|
...basePost,
|
|
@@ -155,12 +155,12 @@ function useSuspensePost(slug) {
|
|
|
155
155
|
return { post: data || null, refetch };
|
|
156
156
|
}
|
|
157
157
|
function useTags() {
|
|
158
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
158
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
159
159
|
const client = createApiClient({
|
|
160
160
|
baseURL: apiBaseURL,
|
|
161
161
|
basePath: apiBasePath
|
|
162
162
|
});
|
|
163
|
-
const queries = createBlogQueryKeys(client);
|
|
163
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
164
164
|
const baseTags = queries.tags.list();
|
|
165
165
|
const { data, isLoading, error, refetch } = useQuery({
|
|
166
166
|
...baseTags,
|
|
@@ -175,12 +175,12 @@ function useTags() {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
function useSuspenseTags() {
|
|
178
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
178
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
179
179
|
const client = createApiClient({
|
|
180
180
|
baseURL: apiBaseURL,
|
|
181
181
|
basePath: apiBasePath
|
|
182
182
|
});
|
|
183
|
-
const queries = createBlogQueryKeys(client);
|
|
183
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
184
184
|
const baseTags = queries.tags.list();
|
|
185
185
|
const { data, refetch, error, isFetching } = useSuspenseQuery({
|
|
186
186
|
...baseTags,
|
|
@@ -334,12 +334,12 @@ function usePostSearch({
|
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
336
|
function useNextPreviousPosts(createdAt, options = {}) {
|
|
337
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
337
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
338
338
|
const client = createApiClient({
|
|
339
339
|
baseURL: apiBaseURL,
|
|
340
340
|
basePath: apiBasePath
|
|
341
341
|
});
|
|
342
|
-
const queries = createBlogQueryKeys(client);
|
|
342
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
343
343
|
const { ref, inView } = useInView({
|
|
344
344
|
// start a little early so the data is ready as it scrolls in
|
|
345
345
|
rootMargin: "200px 0px",
|
|
@@ -364,12 +364,12 @@ function useNextPreviousPosts(createdAt, options = {}) {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
function useRecentPosts(options = {}) {
|
|
367
|
-
const { apiBaseURL, apiBasePath } = usePluginOverrides("blog");
|
|
367
|
+
const { apiBaseURL, apiBasePath, headers } = usePluginOverrides("blog");
|
|
368
368
|
const client = createApiClient({
|
|
369
369
|
baseURL: apiBaseURL,
|
|
370
370
|
basePath: apiBasePath
|
|
371
371
|
});
|
|
372
|
-
const queries = createBlogQueryKeys(client);
|
|
372
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
373
373
|
const { ref, inView } = useInView({
|
|
374
374
|
// start a little early so the data is ready as it scrolls in
|
|
375
375
|
rootMargin: "200px 0px",
|
|
@@ -13,7 +13,7 @@ const postPage = require('./components/pages/post-page.cjs');
|
|
|
13
13
|
function createPostsLoader(published, config) {
|
|
14
14
|
return async () => {
|
|
15
15
|
if (typeof window === "undefined") {
|
|
16
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
16
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
17
17
|
const context = {
|
|
18
18
|
path: published ? "/blog" : "/blog/drafts",
|
|
19
19
|
isSSR: true,
|
|
@@ -32,7 +32,7 @@ function createPostsLoader(published, config) {
|
|
|
32
32
|
baseURL: apiBaseURL,
|
|
33
33
|
basePath: apiBasePath
|
|
34
34
|
});
|
|
35
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
35
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
36
36
|
const listQuery = queries.posts.list({
|
|
37
37
|
query: void 0,
|
|
38
38
|
limit,
|
|
@@ -66,7 +66,7 @@ function createPostsLoader(published, config) {
|
|
|
66
66
|
function createPostLoader(slug, config) {
|
|
67
67
|
return async () => {
|
|
68
68
|
if (typeof window === "undefined") {
|
|
69
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
69
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
70
70
|
const context = {
|
|
71
71
|
path: `/blog/${slug}`,
|
|
72
72
|
params: { slug },
|
|
@@ -85,7 +85,7 @@ function createPostLoader(slug, config) {
|
|
|
85
85
|
baseURL: apiBaseURL,
|
|
86
86
|
basePath: apiBasePath
|
|
87
87
|
});
|
|
88
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
88
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
89
89
|
const postQuery = queries.posts.detail(slug);
|
|
90
90
|
await queryClient.prefetchQuery(postQuery);
|
|
91
91
|
if (hooks?.afterLoadPost) {
|
|
@@ -110,7 +110,7 @@ function createPostLoader(slug, config) {
|
|
|
110
110
|
function createTagLoader(tagSlug, config) {
|
|
111
111
|
return async () => {
|
|
112
112
|
if (typeof window === "undefined") {
|
|
113
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
113
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
114
114
|
const context = {
|
|
115
115
|
path: `/blog/tag/${tagSlug}`,
|
|
116
116
|
params: { tagSlug },
|
|
@@ -124,7 +124,7 @@ function createTagLoader(tagSlug, config) {
|
|
|
124
124
|
baseURL: apiBaseURL,
|
|
125
125
|
basePath: apiBasePath
|
|
126
126
|
});
|
|
127
|
-
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1);
|
|
127
|
+
const queries = plugins_blog_queryKeys.createBlogQueryKeys(client$1, headers);
|
|
128
128
|
const listQuery = queries.posts.list({
|
|
129
129
|
query: void 0,
|
|
130
130
|
limit,
|
|
@@ -11,7 +11,7 @@ import { PostPageComponent } from './components/pages/post-page.mjs';
|
|
|
11
11
|
function createPostsLoader(published, config) {
|
|
12
12
|
return async () => {
|
|
13
13
|
if (typeof window === "undefined") {
|
|
14
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
14
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
15
15
|
const context = {
|
|
16
16
|
path: published ? "/blog" : "/blog/drafts",
|
|
17
17
|
isSSR: true,
|
|
@@ -30,7 +30,7 @@ function createPostsLoader(published, config) {
|
|
|
30
30
|
baseURL: apiBaseURL,
|
|
31
31
|
basePath: apiBasePath
|
|
32
32
|
});
|
|
33
|
-
const queries = createBlogQueryKeys(client);
|
|
33
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
34
34
|
const listQuery = queries.posts.list({
|
|
35
35
|
query: void 0,
|
|
36
36
|
limit,
|
|
@@ -64,7 +64,7 @@ function createPostsLoader(published, config) {
|
|
|
64
64
|
function createPostLoader(slug, config) {
|
|
65
65
|
return async () => {
|
|
66
66
|
if (typeof window === "undefined") {
|
|
67
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
67
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
68
68
|
const context = {
|
|
69
69
|
path: `/blog/${slug}`,
|
|
70
70
|
params: { slug },
|
|
@@ -83,7 +83,7 @@ function createPostLoader(slug, config) {
|
|
|
83
83
|
baseURL: apiBaseURL,
|
|
84
84
|
basePath: apiBasePath
|
|
85
85
|
});
|
|
86
|
-
const queries = createBlogQueryKeys(client);
|
|
86
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
87
87
|
const postQuery = queries.posts.detail(slug);
|
|
88
88
|
await queryClient.prefetchQuery(postQuery);
|
|
89
89
|
if (hooks?.afterLoadPost) {
|
|
@@ -108,7 +108,7 @@ function createPostLoader(slug, config) {
|
|
|
108
108
|
function createTagLoader(tagSlug, config) {
|
|
109
109
|
return async () => {
|
|
110
110
|
if (typeof window === "undefined") {
|
|
111
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
111
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
112
112
|
const context = {
|
|
113
113
|
path: `/blog/tag/${tagSlug}`,
|
|
114
114
|
params: { tagSlug },
|
|
@@ -122,7 +122,7 @@ function createTagLoader(tagSlug, config) {
|
|
|
122
122
|
baseURL: apiBaseURL,
|
|
123
123
|
basePath: apiBasePath
|
|
124
124
|
});
|
|
125
|
-
const queries = createBlogQueryKeys(client);
|
|
125
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
126
126
|
const listQuery = queries.posts.list({
|
|
127
127
|
query: void 0,
|
|
128
128
|
limit,
|
|
@@ -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 {
|
|
@@ -82,9 +82,9 @@ declare function useSuspenseTags(): {
|
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
85
86
|
content: string;
|
|
86
87
|
excerpt: string;
|
|
87
|
-
published: boolean;
|
|
88
88
|
tags: ({
|
|
89
89
|
name: string;
|
|
90
90
|
} | {
|
|
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
|
|
|
93
93
|
slug: string;
|
|
94
94
|
})[];
|
|
95
95
|
slug?: string | undefined;
|
|
96
|
-
publishedAt?: Date | undefined;
|
|
97
96
|
createdAt?: Date | undefined;
|
|
97
|
+
publishedAt?: Date | undefined;
|
|
98
98
|
updatedAt?: Date | undefined;
|
|
99
99
|
image?: string | undefined;
|
|
100
100
|
}, unknown>;
|
|
@@ -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 {
|
|
@@ -82,9 +82,9 @@ declare function useSuspenseTags(): {
|
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
85
86
|
content: string;
|
|
86
87
|
excerpt: string;
|
|
87
|
-
published: boolean;
|
|
88
88
|
tags: ({
|
|
89
89
|
name: string;
|
|
90
90
|
} | {
|
|
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
|
|
|
93
93
|
slug: string;
|
|
94
94
|
})[];
|
|
95
95
|
slug?: string | undefined;
|
|
96
|
-
publishedAt?: Date | undefined;
|
|
97
96
|
createdAt?: Date | undefined;
|
|
97
|
+
publishedAt?: Date | undefined;
|
|
98
98
|
updatedAt?: Date | undefined;
|
|
99
99
|
image?: string | undefined;
|
|
100
100
|
}, unknown>;
|
|
@@ -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 {
|
|
@@ -82,9 +82,9 @@ declare function useSuspenseTags(): {
|
|
|
82
82
|
/** Create a new post */
|
|
83
83
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
84
84
|
title: string;
|
|
85
|
+
published: boolean;
|
|
85
86
|
content: string;
|
|
86
87
|
excerpt: string;
|
|
87
|
-
published: boolean;
|
|
88
88
|
tags: ({
|
|
89
89
|
name: string;
|
|
90
90
|
} | {
|
|
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
|
|
|
93
93
|
slug: string;
|
|
94
94
|
})[];
|
|
95
95
|
slug?: string | undefined;
|
|
96
|
-
publishedAt?: Date | undefined;
|
|
97
96
|
createdAt?: Date | undefined;
|
|
97
|
+
publishedAt?: Date | undefined;
|
|
98
98
|
updatedAt?: Date | undefined;
|
|
99
99
|
image?: string | undefined;
|
|
100
100
|
}, unknown>;
|
|
@@ -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
|
|
|
@@ -45,6 +45,7 @@ interface BlogClientConfig {
|
|
|
45
45
|
defaultImage?: string;
|
|
46
46
|
};
|
|
47
47
|
hooks?: BlogClientHooks;
|
|
48
|
+
headers?: HeadersInit;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Hooks for blog client plugin
|
|
@@ -357,6 +358,10 @@ interface BlogPluginOverrides {
|
|
|
357
358
|
* Whether to show the attribution
|
|
358
359
|
*/
|
|
359
360
|
showAttribution?: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
363
|
+
*/
|
|
364
|
+
headers?: HeadersInit;
|
|
360
365
|
/**
|
|
361
366
|
* Called when a route is rendered
|
|
362
367
|
* @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
|
|
@@ -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
|
|
|
@@ -45,6 +45,7 @@ interface BlogClientConfig {
|
|
|
45
45
|
defaultImage?: string;
|
|
46
46
|
};
|
|
47
47
|
hooks?: BlogClientHooks;
|
|
48
|
+
headers?: HeadersInit;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Hooks for blog client plugin
|
|
@@ -357,6 +358,10 @@ interface BlogPluginOverrides {
|
|
|
357
358
|
* Whether to show the attribution
|
|
358
359
|
*/
|
|
359
360
|
showAttribution?: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
363
|
+
*/
|
|
364
|
+
headers?: HeadersInit;
|
|
360
365
|
/**
|
|
361
366
|
* Called when a route is rendered
|
|
362
367
|
* @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
|
|
@@ -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
|
|
|
@@ -45,6 +45,7 @@ interface BlogClientConfig {
|
|
|
45
45
|
defaultImage?: string;
|
|
46
46
|
};
|
|
47
47
|
hooks?: BlogClientHooks;
|
|
48
|
+
headers?: HeadersInit;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Hooks for blog client plugin
|
|
@@ -357,6 +358,10 @@ interface BlogPluginOverrides {
|
|
|
357
358
|
* Whether to show the attribution
|
|
358
359
|
*/
|
|
359
360
|
showAttribution?: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
363
|
+
*/
|
|
364
|
+
headers?: HeadersInit;
|
|
360
365
|
/**
|
|
361
366
|
* Called when a route is rendered
|
|
362
367
|
* @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
|
|
@@ -18,13 +18,13 @@ function toError(error) {
|
|
|
18
18
|
}
|
|
19
19
|
return new Error(String(error));
|
|
20
20
|
}
|
|
21
|
-
function createBlogQueryKeys(client) {
|
|
22
|
-
const posts = createPostsQueries(client);
|
|
23
|
-
const drafts = createDraftsQueries(client);
|
|
24
|
-
const tags = createTagsQueries(client);
|
|
21
|
+
function createBlogQueryKeys(client, headers) {
|
|
22
|
+
const posts = createPostsQueries(client, headers);
|
|
23
|
+
const drafts = createDraftsQueries(client, headers);
|
|
24
|
+
const tags = createTagsQueries(client, headers);
|
|
25
25
|
return queryKeyFactory.mergeQueryKeys(posts, drafts, tags);
|
|
26
26
|
}
|
|
27
|
-
function createPostsQueries(client) {
|
|
27
|
+
function createPostsQueries(client, headers) {
|
|
28
28
|
return queryKeyFactory.createQueryKeys("posts", {
|
|
29
29
|
list: (params) => ({
|
|
30
30
|
queryKey: [
|
|
@@ -45,7 +45,8 @@ function createPostsQueries(client) {
|
|
|
45
45
|
limit: params?.limit ?? 10,
|
|
46
46
|
published: params?.published !== void 0 ? params.published ? "true" : "false" : void 0,
|
|
47
47
|
tagSlug: params?.tagSlug
|
|
48
|
-
}
|
|
48
|
+
},
|
|
49
|
+
headers
|
|
49
50
|
});
|
|
50
51
|
if (isErrorResponse(response)) {
|
|
51
52
|
const errorResponse = response;
|
|
@@ -65,7 +66,8 @@ function createPostsQueries(client) {
|
|
|
65
66
|
try {
|
|
66
67
|
const response = await client("/posts", {
|
|
67
68
|
method: "GET",
|
|
68
|
-
query: { slug, limit: 1 }
|
|
69
|
+
query: { slug, limit: 1 },
|
|
70
|
+
headers
|
|
69
71
|
});
|
|
70
72
|
if (isErrorResponse(response)) {
|
|
71
73
|
const errorResponse = response;
|
|
@@ -87,7 +89,8 @@ function createPostsQueries(client) {
|
|
|
87
89
|
method: "GET",
|
|
88
90
|
query: {
|
|
89
91
|
date: dateValue.toISOString()
|
|
90
|
-
}
|
|
92
|
+
},
|
|
93
|
+
headers
|
|
91
94
|
});
|
|
92
95
|
if (isErrorResponse(response)) {
|
|
93
96
|
const errorResponse = response;
|
|
@@ -107,7 +110,8 @@ function createPostsQueries(client) {
|
|
|
107
110
|
query: {
|
|
108
111
|
limit: params?.limit ?? 5,
|
|
109
112
|
published: "true"
|
|
110
|
-
}
|
|
113
|
+
},
|
|
114
|
+
headers
|
|
111
115
|
});
|
|
112
116
|
if (isErrorResponse(response)) {
|
|
113
117
|
const errorResponse = response;
|
|
@@ -125,7 +129,7 @@ function createPostsQueries(client) {
|
|
|
125
129
|
})
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
|
-
function createDraftsQueries(client) {
|
|
132
|
+
function createDraftsQueries(client, headers) {
|
|
129
133
|
return queryKeyFactory.createQueryKeys("drafts", {
|
|
130
134
|
list: (params) => ({
|
|
131
135
|
queryKey: [
|
|
@@ -142,7 +146,8 @@ function createDraftsQueries(client) {
|
|
|
142
146
|
offset: pageParam ?? 0,
|
|
143
147
|
limit: params?.limit ?? 10,
|
|
144
148
|
published: "false"
|
|
145
|
-
}
|
|
149
|
+
},
|
|
150
|
+
headers
|
|
146
151
|
});
|
|
147
152
|
if (isErrorResponse(response)) {
|
|
148
153
|
const errorResponse = response;
|
|
@@ -156,14 +161,15 @@ function createDraftsQueries(client) {
|
|
|
156
161
|
})
|
|
157
162
|
});
|
|
158
163
|
}
|
|
159
|
-
function createTagsQueries(client) {
|
|
164
|
+
function createTagsQueries(client, headers) {
|
|
160
165
|
return queryKeyFactory.createQueryKeys("tags", {
|
|
161
166
|
list: () => ({
|
|
162
167
|
queryKey: ["tags"],
|
|
163
168
|
queryFn: async () => {
|
|
164
169
|
try {
|
|
165
170
|
const response = await client("/tags", {
|
|
166
|
-
method: "GET"
|
|
171
|
+
method: "GET",
|
|
172
|
+
headers
|
|
167
173
|
});
|
|
168
174
|
if (isErrorResponse(response)) {
|
|
169
175
|
const errorResponse = response;
|
|
@@ -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
|
|
|
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
135
135
|
content: string;
|
|
136
136
|
excerpt: string;
|
|
137
137
|
slug?: string | undefined;
|
|
138
|
-
|
|
138
|
+
published?: boolean | undefined;
|
|
139
139
|
createdAt?: unknown;
|
|
140
|
+
publishedAt?: unknown;
|
|
140
141
|
updatedAt?: unknown;
|
|
141
142
|
image?: string | undefined;
|
|
142
|
-
published?: boolean | undefined;
|
|
143
143
|
tags?: ({
|
|
144
144
|
name: string;
|
|
145
145
|
} | {
|
|
@@ -173,15 +173,15 @@ 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>>;
|
|
180
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
|
-
title: z.ZodString;
|
|
181
182
|
content: z.ZodString;
|
|
182
183
|
excerpt: z.ZodString;
|
|
183
184
|
image: z.ZodOptional<z.ZodString>;
|
|
184
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
185
185
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
186
186
|
name: z.ZodString;
|
|
187
187
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -438,7 +438,7 @@ interface PostsListParams {
|
|
|
438
438
|
published?: boolean;
|
|
439
439
|
tagSlug?: string;
|
|
440
440
|
}
|
|
441
|
-
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter
|
|
441
|
+
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
|
|
442
442
|
posts: {
|
|
443
443
|
_def: readonly ["posts"];
|
|
444
444
|
} & {
|
|
@@ -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
|
|
|
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
135
135
|
content: string;
|
|
136
136
|
excerpt: string;
|
|
137
137
|
slug?: string | undefined;
|
|
138
|
-
|
|
138
|
+
published?: boolean | undefined;
|
|
139
139
|
createdAt?: unknown;
|
|
140
|
+
publishedAt?: unknown;
|
|
140
141
|
updatedAt?: unknown;
|
|
141
142
|
image?: string | undefined;
|
|
142
|
-
published?: boolean | undefined;
|
|
143
143
|
tags?: ({
|
|
144
144
|
name: string;
|
|
145
145
|
} | {
|
|
@@ -173,15 +173,15 @@ 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>>;
|
|
180
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
|
-
title: z.ZodString;
|
|
181
182
|
content: z.ZodString;
|
|
182
183
|
excerpt: z.ZodString;
|
|
183
184
|
image: z.ZodOptional<z.ZodString>;
|
|
184
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
185
185
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
186
186
|
name: z.ZodString;
|
|
187
187
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -438,7 +438,7 @@ interface PostsListParams {
|
|
|
438
438
|
published?: boolean;
|
|
439
439
|
tagSlug?: string;
|
|
440
440
|
}
|
|
441
|
-
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter
|
|
441
|
+
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
|
|
442
442
|
posts: {
|
|
443
443
|
_def: readonly ["posts"];
|
|
444
444
|
} & {
|
|
@@ -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
|
|
|
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
|
|
|
135
135
|
content: string;
|
|
136
136
|
excerpt: string;
|
|
137
137
|
slug?: string | undefined;
|
|
138
|
-
|
|
138
|
+
published?: boolean | undefined;
|
|
139
139
|
createdAt?: unknown;
|
|
140
|
+
publishedAt?: unknown;
|
|
140
141
|
updatedAt?: unknown;
|
|
141
142
|
image?: string | undefined;
|
|
142
|
-
published?: boolean | undefined;
|
|
143
143
|
tags?: ({
|
|
144
144
|
name: string;
|
|
145
145
|
} | {
|
|
@@ -173,15 +173,15 @@ 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>>;
|
|
180
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
179
181
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
180
|
-
title: z.ZodString;
|
|
181
182
|
content: z.ZodString;
|
|
182
183
|
excerpt: z.ZodString;
|
|
183
184
|
image: z.ZodOptional<z.ZodString>;
|
|
184
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
185
185
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
186
186
|
name: z.ZodString;
|
|
187
187
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -438,7 +438,7 @@ interface PostsListParams {
|
|
|
438
438
|
published?: boolean;
|
|
439
439
|
tagSlug?: string;
|
|
440
440
|
}
|
|
441
|
-
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter
|
|
441
|
+
declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
|
|
442
442
|
posts: {
|
|
443
443
|
_def: readonly ["posts"];
|
|
444
444
|
} & {
|
|
@@ -16,13 +16,13 @@ function toError(error) {
|
|
|
16
16
|
}
|
|
17
17
|
return new Error(String(error));
|
|
18
18
|
}
|
|
19
|
-
function createBlogQueryKeys(client) {
|
|
20
|
-
const posts = createPostsQueries(client);
|
|
21
|
-
const drafts = createDraftsQueries(client);
|
|
22
|
-
const tags = createTagsQueries(client);
|
|
19
|
+
function createBlogQueryKeys(client, headers) {
|
|
20
|
+
const posts = createPostsQueries(client, headers);
|
|
21
|
+
const drafts = createDraftsQueries(client, headers);
|
|
22
|
+
const tags = createTagsQueries(client, headers);
|
|
23
23
|
return mergeQueryKeys(posts, drafts, tags);
|
|
24
24
|
}
|
|
25
|
-
function createPostsQueries(client) {
|
|
25
|
+
function createPostsQueries(client, headers) {
|
|
26
26
|
return createQueryKeys("posts", {
|
|
27
27
|
list: (params) => ({
|
|
28
28
|
queryKey: [
|
|
@@ -43,7 +43,8 @@ function createPostsQueries(client) {
|
|
|
43
43
|
limit: params?.limit ?? 10,
|
|
44
44
|
published: params?.published !== void 0 ? params.published ? "true" : "false" : void 0,
|
|
45
45
|
tagSlug: params?.tagSlug
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
|
+
headers
|
|
47
48
|
});
|
|
48
49
|
if (isErrorResponse(response)) {
|
|
49
50
|
const errorResponse = response;
|
|
@@ -63,7 +64,8 @@ function createPostsQueries(client) {
|
|
|
63
64
|
try {
|
|
64
65
|
const response = await client("/posts", {
|
|
65
66
|
method: "GET",
|
|
66
|
-
query: { slug, limit: 1 }
|
|
67
|
+
query: { slug, limit: 1 },
|
|
68
|
+
headers
|
|
67
69
|
});
|
|
68
70
|
if (isErrorResponse(response)) {
|
|
69
71
|
const errorResponse = response;
|
|
@@ -85,7 +87,8 @@ function createPostsQueries(client) {
|
|
|
85
87
|
method: "GET",
|
|
86
88
|
query: {
|
|
87
89
|
date: dateValue.toISOString()
|
|
88
|
-
}
|
|
90
|
+
},
|
|
91
|
+
headers
|
|
89
92
|
});
|
|
90
93
|
if (isErrorResponse(response)) {
|
|
91
94
|
const errorResponse = response;
|
|
@@ -105,7 +108,8 @@ function createPostsQueries(client) {
|
|
|
105
108
|
query: {
|
|
106
109
|
limit: params?.limit ?? 5,
|
|
107
110
|
published: "true"
|
|
108
|
-
}
|
|
111
|
+
},
|
|
112
|
+
headers
|
|
109
113
|
});
|
|
110
114
|
if (isErrorResponse(response)) {
|
|
111
115
|
const errorResponse = response;
|
|
@@ -123,7 +127,7 @@ function createPostsQueries(client) {
|
|
|
123
127
|
})
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
|
-
function createDraftsQueries(client) {
|
|
130
|
+
function createDraftsQueries(client, headers) {
|
|
127
131
|
return createQueryKeys("drafts", {
|
|
128
132
|
list: (params) => ({
|
|
129
133
|
queryKey: [
|
|
@@ -140,7 +144,8 @@ function createDraftsQueries(client) {
|
|
|
140
144
|
offset: pageParam ?? 0,
|
|
141
145
|
limit: params?.limit ?? 10,
|
|
142
146
|
published: "false"
|
|
143
|
-
}
|
|
147
|
+
},
|
|
148
|
+
headers
|
|
144
149
|
});
|
|
145
150
|
if (isErrorResponse(response)) {
|
|
146
151
|
const errorResponse = response;
|
|
@@ -154,14 +159,15 @@ function createDraftsQueries(client) {
|
|
|
154
159
|
})
|
|
155
160
|
});
|
|
156
161
|
}
|
|
157
|
-
function createTagsQueries(client) {
|
|
162
|
+
function createTagsQueries(client, headers) {
|
|
158
163
|
return createQueryKeys("tags", {
|
|
159
164
|
list: () => ({
|
|
160
165
|
queryKey: ["tags"],
|
|
161
166
|
queryFn: async () => {
|
|
162
167
|
try {
|
|
163
168
|
const response = await client("/tags", {
|
|
164
|
-
method: "GET"
|
|
169
|
+
method: "GET",
|
|
170
|
+
headers
|
|
165
171
|
});
|
|
166
172
|
if (isErrorResponse(response)) {
|
|
167
173
|
const errorResponse = response;
|
package/package.json
CHANGED
|
@@ -86,7 +86,7 @@ export type PostUpdateInput = z.infer<typeof updatePostSchema>;
|
|
|
86
86
|
* Hook for fetching paginated posts with load more functionality
|
|
87
87
|
*/
|
|
88
88
|
export function usePosts(options: UsePostsOptions = {}): UsePostsResult {
|
|
89
|
-
const { apiBaseURL, apiBasePath } =
|
|
89
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
90
90
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
91
91
|
const client = createApiClient<BlogApiRouter>({
|
|
92
92
|
baseURL: apiBaseURL,
|
|
@@ -100,7 +100,7 @@ export function usePosts(options: UsePostsOptions = {}): UsePostsResult {
|
|
|
100
100
|
query,
|
|
101
101
|
published,
|
|
102
102
|
} = options;
|
|
103
|
-
const queries = createBlogQueryKeys(client);
|
|
103
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
104
104
|
|
|
105
105
|
const queryParams = {
|
|
106
106
|
tag,
|
|
@@ -155,7 +155,7 @@ export function useSuspensePosts(options: UsePostsOptions = {}): {
|
|
|
155
155
|
isLoadingMore: boolean;
|
|
156
156
|
refetch: () => Promise<unknown>;
|
|
157
157
|
} {
|
|
158
|
-
const { apiBaseURL, apiBasePath } =
|
|
158
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
159
159
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
160
160
|
const client = createApiClient<BlogApiRouter>({
|
|
161
161
|
baseURL: apiBaseURL,
|
|
@@ -169,7 +169,7 @@ export function useSuspensePosts(options: UsePostsOptions = {}): {
|
|
|
169
169
|
query,
|
|
170
170
|
published,
|
|
171
171
|
} = options;
|
|
172
|
-
const queries = createBlogQueryKeys(client);
|
|
172
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
173
173
|
|
|
174
174
|
const queryParams = { tag, tagSlug, limit, query, published };
|
|
175
175
|
const basePosts = queries.posts.list(queryParams);
|
|
@@ -214,13 +214,13 @@ export function useSuspensePosts(options: UsePostsOptions = {}): {
|
|
|
214
214
|
* Hook for fetching a single post by slug
|
|
215
215
|
*/
|
|
216
216
|
export function usePost(slug?: string): UsePostResult {
|
|
217
|
-
const { apiBaseURL, apiBasePath } =
|
|
217
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
218
218
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
219
219
|
const client = createApiClient<BlogApiRouter>({
|
|
220
220
|
baseURL: apiBaseURL,
|
|
221
221
|
basePath: apiBasePath,
|
|
222
222
|
});
|
|
223
|
-
const queries = createBlogQueryKeys(client);
|
|
223
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
224
224
|
|
|
225
225
|
const basePost = queries.posts.detail(slug ?? "");
|
|
226
226
|
const { data, isLoading, error, refetch } = useQuery<
|
|
@@ -247,13 +247,13 @@ export function useSuspensePost(slug: string): {
|
|
|
247
247
|
post: SerializedPost | null;
|
|
248
248
|
refetch: () => Promise<unknown>;
|
|
249
249
|
} {
|
|
250
|
-
const { apiBaseURL, apiBasePath } =
|
|
250
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
251
251
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
252
252
|
const client = createApiClient<BlogApiRouter>({
|
|
253
253
|
baseURL: apiBaseURL,
|
|
254
254
|
basePath: apiBasePath,
|
|
255
255
|
});
|
|
256
|
-
const queries = createBlogQueryKeys(client);
|
|
256
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
257
257
|
const basePost = queries.posts.detail(slug);
|
|
258
258
|
const { data, refetch, error, isFetching } = useSuspenseQuery<
|
|
259
259
|
SerializedPost | null,
|
|
@@ -283,13 +283,13 @@ export function useTags(): {
|
|
|
283
283
|
error: Error | null;
|
|
284
284
|
refetch: () => void;
|
|
285
285
|
} {
|
|
286
|
-
const { apiBaseURL, apiBasePath } =
|
|
286
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
287
287
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
288
288
|
const client = createApiClient<BlogApiRouter>({
|
|
289
289
|
baseURL: apiBaseURL,
|
|
290
290
|
basePath: apiBasePath,
|
|
291
291
|
});
|
|
292
|
-
const queries = createBlogQueryKeys(client);
|
|
292
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
293
293
|
const baseTags = queries.tags.list();
|
|
294
294
|
const { data, isLoading, error, refetch } = useQuery<
|
|
295
295
|
SerializedTag[] | null,
|
|
@@ -315,13 +315,13 @@ export function useSuspenseTags(): {
|
|
|
315
315
|
tags: SerializedTag[];
|
|
316
316
|
refetch: () => Promise<unknown>;
|
|
317
317
|
} {
|
|
318
|
-
const { apiBaseURL, apiBasePath } =
|
|
318
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
319
319
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
320
320
|
const client = createApiClient<BlogApiRouter>({
|
|
321
321
|
baseURL: apiBaseURL,
|
|
322
322
|
basePath: apiBasePath,
|
|
323
323
|
});
|
|
324
|
-
const queries = createBlogQueryKeys(client);
|
|
324
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
325
325
|
const baseTags = queries.tags.list();
|
|
326
326
|
const { data, refetch, error, isFetching } = useSuspenseQuery<
|
|
327
327
|
SerializedTag[] | null,
|
|
@@ -555,13 +555,13 @@ export function useNextPreviousPosts(
|
|
|
555
555
|
ref: (node: Element | null) => void;
|
|
556
556
|
inView: boolean;
|
|
557
557
|
} {
|
|
558
|
-
const { apiBaseURL, apiBasePath } =
|
|
558
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
559
559
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
560
560
|
const client = createApiClient<BlogApiRouter>({
|
|
561
561
|
baseURL: apiBaseURL,
|
|
562
562
|
basePath: apiBasePath,
|
|
563
563
|
});
|
|
564
|
-
const queries = createBlogQueryKeys(client);
|
|
564
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
565
565
|
|
|
566
566
|
const { ref, inView } = useInView({
|
|
567
567
|
// start a little early so the data is ready as it scrolls in
|
|
@@ -619,13 +619,13 @@ export function useRecentPosts(
|
|
|
619
619
|
ref: (node: Element | null) => void;
|
|
620
620
|
inView: boolean;
|
|
621
621
|
} {
|
|
622
|
-
const { apiBaseURL, apiBasePath } =
|
|
622
|
+
const { apiBaseURL, apiBasePath, headers } =
|
|
623
623
|
usePluginOverrides<BlogPluginOverrides>("blog");
|
|
624
624
|
const client = createApiClient<BlogApiRouter>({
|
|
625
625
|
baseURL: apiBaseURL,
|
|
626
626
|
basePath: apiBasePath,
|
|
627
627
|
});
|
|
628
|
-
const queries = createBlogQueryKeys(client);
|
|
628
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
629
629
|
|
|
630
630
|
const { ref, inView } = useInView({
|
|
631
631
|
// start a little early so the data is ready as it scrolls in
|
|
@@ -57,6 +57,10 @@ export interface BlogPluginOverrides {
|
|
|
57
57
|
* Whether to show the attribution
|
|
58
58
|
*/
|
|
59
59
|
showAttribution?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Optional headers to pass with API requests (e.g., for SSR auth)
|
|
62
|
+
*/
|
|
63
|
+
headers?: HeadersInit;
|
|
60
64
|
|
|
61
65
|
// Lifecycle Hooks (optional)
|
|
62
66
|
/**
|
|
@@ -58,6 +58,9 @@ export interface BlogClientConfig {
|
|
|
58
58
|
|
|
59
59
|
// Optional hooks
|
|
60
60
|
hooks?: BlogClientHooks;
|
|
61
|
+
|
|
62
|
+
// Optional headers for SSR (e.g., forwarding cookies)
|
|
63
|
+
headers?: HeadersInit;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
/**
|
|
@@ -91,7 +94,7 @@ export interface BlogClientHooks {
|
|
|
91
94
|
function createPostsLoader(published: boolean, config: BlogClientConfig) {
|
|
92
95
|
return async () => {
|
|
93
96
|
if (typeof window === "undefined") {
|
|
94
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
97
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
95
98
|
|
|
96
99
|
const context: LoaderContext = {
|
|
97
100
|
path: published ? "/blog" : "/blog/drafts",
|
|
@@ -116,7 +119,7 @@ function createPostsLoader(published: boolean, config: BlogClientConfig) {
|
|
|
116
119
|
});
|
|
117
120
|
|
|
118
121
|
// note: for a module not to be bundled with client, and to be shared by client and server we need to add it to build.config.ts as an entry
|
|
119
|
-
const queries = createBlogQueryKeys(client);
|
|
122
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
120
123
|
const listQuery = queries.posts.list({
|
|
121
124
|
query: undefined,
|
|
122
125
|
limit,
|
|
@@ -170,7 +173,7 @@ function createPostsLoader(published: boolean, config: BlogClientConfig) {
|
|
|
170
173
|
function createPostLoader(slug: string, config: BlogClientConfig) {
|
|
171
174
|
return async () => {
|
|
172
175
|
if (typeof window === "undefined") {
|
|
173
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
176
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
174
177
|
|
|
175
178
|
const context: LoaderContext = {
|
|
176
179
|
path: `/blog/${slug}`,
|
|
@@ -193,7 +196,7 @@ function createPostLoader(slug: string, config: BlogClientConfig) {
|
|
|
193
196
|
baseURL: apiBaseURL,
|
|
194
197
|
basePath: apiBasePath,
|
|
195
198
|
});
|
|
196
|
-
const queries = createBlogQueryKeys(client);
|
|
199
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
197
200
|
const postQuery = queries.posts.detail(slug);
|
|
198
201
|
await queryClient.prefetchQuery(postQuery);
|
|
199
202
|
|
|
@@ -235,7 +238,7 @@ function createPostLoader(slug: string, config: BlogClientConfig) {
|
|
|
235
238
|
function createTagLoader(tagSlug: string, config: BlogClientConfig) {
|
|
236
239
|
return async () => {
|
|
237
240
|
if (typeof window === "undefined") {
|
|
238
|
-
const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
|
|
241
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
239
242
|
|
|
240
243
|
const context: LoaderContext = {
|
|
241
244
|
path: `/blog/tag/${tagSlug}`,
|
|
@@ -252,7 +255,7 @@ function createTagLoader(tagSlug: string, config: BlogClientConfig) {
|
|
|
252
255
|
basePath: apiBasePath,
|
|
253
256
|
});
|
|
254
257
|
|
|
255
|
-
const queries = createBlogQueryKeys(client);
|
|
258
|
+
const queries = createBlogQueryKeys(client, headers);
|
|
256
259
|
const listQuery = queries.posts.list({
|
|
257
260
|
query: undefined,
|
|
258
261
|
limit,
|
|
@@ -55,16 +55,18 @@ function toError(error: unknown): Error {
|
|
|
55
55
|
|
|
56
56
|
export function createBlogQueryKeys(
|
|
57
57
|
client: ReturnType<typeof createApiClient<BlogApiRouter>>,
|
|
58
|
+
headers?: HeadersInit,
|
|
58
59
|
) {
|
|
59
|
-
const posts = createPostsQueries(client);
|
|
60
|
-
const drafts = createDraftsQueries(client);
|
|
61
|
-
const tags = createTagsQueries(client);
|
|
60
|
+
const posts = createPostsQueries(client, headers);
|
|
61
|
+
const drafts = createDraftsQueries(client, headers);
|
|
62
|
+
const tags = createTagsQueries(client, headers);
|
|
62
63
|
|
|
63
64
|
return mergeQueryKeys(posts, drafts, tags);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
function createPostsQueries(
|
|
67
68
|
client: ReturnType<typeof createApiClient<BlogApiRouter>>,
|
|
69
|
+
headers?: HeadersInit,
|
|
68
70
|
) {
|
|
69
71
|
return createQueryKeys("posts", {
|
|
70
72
|
list: (params?: PostsListParams) => ({
|
|
@@ -95,6 +97,7 @@ function createPostsQueries(
|
|
|
95
97
|
: undefined,
|
|
96
98
|
tagSlug: params?.tagSlug,
|
|
97
99
|
},
|
|
100
|
+
headers,
|
|
98
101
|
});
|
|
99
102
|
// Check for errors (better-call returns Error$1<unknown> | Data<Post[]>)
|
|
100
103
|
if (isErrorResponse(response)) {
|
|
@@ -121,6 +124,7 @@ function createPostsQueries(
|
|
|
121
124
|
const response = await client("/posts", {
|
|
122
125
|
method: "GET",
|
|
123
126
|
query: { slug, limit: 1 },
|
|
127
|
+
headers,
|
|
124
128
|
});
|
|
125
129
|
// Check for errors (better-call returns Error$1<unknown> | Data<Post[]>)
|
|
126
130
|
if (isErrorResponse(response)) {
|
|
@@ -148,6 +152,7 @@ function createPostsQueries(
|
|
|
148
152
|
query: {
|
|
149
153
|
date: dateValue.toISOString(),
|
|
150
154
|
},
|
|
155
|
+
headers,
|
|
151
156
|
});
|
|
152
157
|
// Check for errors (better-call returns Error$1<unknown> | Data<...>)
|
|
153
158
|
if (isErrorResponse(response)) {
|
|
@@ -174,6 +179,7 @@ function createPostsQueries(
|
|
|
174
179
|
limit: params?.limit ?? 5,
|
|
175
180
|
published: "true",
|
|
176
181
|
},
|
|
182
|
+
headers,
|
|
177
183
|
});
|
|
178
184
|
// Check for errors (better-call returns Error$1<unknown> | Data<Post[]>)
|
|
179
185
|
if (isErrorResponse(response)) {
|
|
@@ -201,6 +207,7 @@ function createPostsQueries(
|
|
|
201
207
|
|
|
202
208
|
function createDraftsQueries(
|
|
203
209
|
client: ReturnType<typeof createApiClient<BlogApiRouter>>,
|
|
210
|
+
headers?: HeadersInit,
|
|
204
211
|
) {
|
|
205
212
|
return createQueryKeys("drafts", {
|
|
206
213
|
list: (params?: PostsListParams) => ({
|
|
@@ -219,6 +226,7 @@ function createDraftsQueries(
|
|
|
219
226
|
limit: params?.limit ?? 10,
|
|
220
227
|
published: "false",
|
|
221
228
|
},
|
|
229
|
+
headers,
|
|
222
230
|
});
|
|
223
231
|
// Check for errors (better-call returns Error$1<unknown> | Data<Post[]>)
|
|
224
232
|
if (isErrorResponse(response)) {
|
|
@@ -239,6 +247,7 @@ function createDraftsQueries(
|
|
|
239
247
|
|
|
240
248
|
function createTagsQueries(
|
|
241
249
|
client: ReturnType<typeof createApiClient<BlogApiRouter>>,
|
|
250
|
+
headers?: HeadersInit,
|
|
242
251
|
) {
|
|
243
252
|
return createQueryKeys("tags", {
|
|
244
253
|
list: () => ({
|
|
@@ -247,6 +256,7 @@ function createTagsQueries(
|
|
|
247
256
|
try {
|
|
248
257
|
const response = await client("/tags", {
|
|
249
258
|
method: "GET",
|
|
259
|
+
headers,
|
|
250
260
|
});
|
|
251
261
|
// Check for errors (better-call returns Error$1<unknown> | Data<Tag[]>)
|
|
252
262
|
if (isErrorResponse(response)) {
|
|
@@ -35,15 +35,15 @@ 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>>;
|
|
42
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
|
-
title: z.ZodString;
|
|
43
44
|
content: z.ZodString;
|
|
44
45
|
excerpt: z.ZodString;
|
|
45
46
|
image: z.ZodOptional<z.ZodString>;
|
|
46
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
47
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
48
48
|
name: z.ZodString;
|
|
49
49
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -35,15 +35,15 @@ 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>>;
|
|
42
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
|
-
title: z.ZodString;
|
|
43
44
|
content: z.ZodString;
|
|
44
45
|
excerpt: z.ZodString;
|
|
45
46
|
image: z.ZodOptional<z.ZodString>;
|
|
46
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
47
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
48
48
|
name: z.ZodString;
|
|
49
49
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -35,15 +35,15 @@ 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>>;
|
|
42
|
+
publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
41
43
|
updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
42
|
-
title: z.ZodString;
|
|
43
44
|
content: z.ZodString;
|
|
44
45
|
excerpt: z.ZodString;
|
|
45
46
|
image: z.ZodOptional<z.ZodString>;
|
|
46
|
-
published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
47
|
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
48
48
|
name: z.ZodString;
|
|
49
49
|
}, z.core.$strip>, z.ZodObject<{
|