@@ -120,12 +120,14 @@ make_async_trait!(GetBuildPathsFnType, RenderFnResult<Vec<String>>);
120
120
make_async_trait ! (
121
121
GetBuildStateFnType ,
122
122
RenderFnResultWithCause <String >,
123
- path: String
123
+ path: String ,
124
+ locale: String
124
125
) ;
125
126
make_async_trait ! (
126
127
GetRequestStateFnType ,
127
128
RenderFnResultWithCause <String >,
128
129
path: String ,
130
+ locale: String ,
129
131
req: Request
130
132
) ;
131
133
make_async_trait ! ( ShouldRevalidateFnType , RenderFnResultWithCause <bool >) ;
@@ -279,10 +281,15 @@ impl<G: GenericNode> Template<G> {
279
281
}
280
282
}
281
283
/// Gets the initial state for a template. This needs to be passed the full path of the template, which may be one of those generated by
282
- /// `.get_build_paths()`.
283
- pub async fn get_build_state ( & self , path : String ) -> Result < String , ServerError > {
284
+ /// `.get_build_paths()`. This also needs the locale being rendered to so that more compelx applications like custom documentation
285
+ /// systems can be enabled.
286
+ pub async fn get_build_state (
287
+ & self ,
288
+ path : String ,
289
+ locale : String ,
290
+ ) -> Result < String , ServerError > {
284
291
if let Some ( get_build_state) = & self . get_build_state {
285
- let res = get_build_state. call ( path) . await ;
292
+ let res = get_build_state. call ( path, locale ) . await ;
286
293
match res {
287
294
Ok ( res) => Ok ( res) ,
288
295
Err ( GenericErrorWithCause { error, cause } ) => Err ( ServerError :: RenderFnFailed {
@@ -302,14 +309,15 @@ impl<G: GenericNode> Template<G> {
302
309
}
303
310
/// Gets the request-time state for a template. This is equivalent to SSR, and will not be performed at build-time. Unlike
304
311
/// `.get_build_paths()` though, this will be passed information about the request that triggered the render. Errors here can be caused
305
- /// by either the server or the client, so the user must specify an [`ErrorCause`].
312
+ /// by either the server or the client, so the user must specify an [`ErrorCause`]. This is also passed the locale being rendered to.
306
313
pub async fn get_request_state (
307
314
& self ,
308
315
path : String ,
316
+ locale : String ,
309
317
req : Request ,
310
318
) -> Result < String , ServerError > {
311
319
if let Some ( get_request_state) = & self . get_request_state {
312
- let res = get_request_state. call ( path, req) . await ;
320
+ let res = get_request_state. call ( path, locale , req) . await ;
313
321
match res {
314
322
Ok ( res) => Ok ( res) ,
315
323
Err ( GenericErrorWithCause { error, cause } ) => Err ( ServerError :: RenderFnFailed {
0 commit comments