Skip to content

Commit cb60be0

Browse files
committed
refactor: ♻️ renamed incremental_path_rendering to incremental_generation and improved interface
BREAKING CHANGE: renamed `incremental_path_rendering` to `incremental_generation`, and the corresponding template function no longer takes a value
1 parent 2105f5a commit cb60be0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

examples/showcase/src/templates/post.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn get_template<G: GenericNode>() -> Template<G> {
2727
Template::new("post")
2828
.build_paths_fn(Rc::new(get_static_paths))
2929
.build_state_fn(Rc::new(get_static_props))
30-
.incremental_path_rendering(true)
30+
.incremental_generation()
3131
.template(template_fn())
3232
}
3333

examples/showcase/src/templates/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn get_template<G: GenericNode>() -> Template<G> {
2020
.template(template_fn())
2121
// This page will revalidate every five seconds (to illustrate revalidation)
2222
.revalidate_after("5s".to_string())
23-
.incremental_path_rendering(true)
23+
.incremental_generation()
2424
.build_state_fn(Rc::new(get_build_state))
2525
.build_paths_fn(Rc::new(get_build_paths))
2626
}

packages/perseus/src/template.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ pub struct Template<G: GenericNode> {
147147
/// so reactivity here will not work!
148148
head: TemplateFn<SsrNode>,
149149
/// A function that gets the paths to render for at built-time. This is equivalent to `get_static_paths` in NextJS. If
150-
/// `incremental_path_rendering` is `true`, more paths can be rendered at request time on top of these.
150+
/// `incremental_generation` is `true`, more paths can be rendered at request time on top of these.
151151
get_build_paths: Option<GetBuildPathsFn>,
152152
/// Defines whether or not any new paths that match this template will be prerendered and cached in production. This allows you to
153153
/// have potentially billions of templates and retain a super-fast build process. The first user will have an ever-so-slightly slower
154154
/// experience, and everyone else gets the beneftis afterwards. This requires `get_build_paths`. Note that the template root will NOT
155155
/// be rendered on demand, and must be explicitly defined if it's wanted. It can uuse a different template.
156-
incremental_path_rendering: bool,
156+
incremental_generation: bool,
157157
/// A function that gets the initial state to use to prerender the template at build time. This will be passed the path of the template, and
158158
/// will be run for any sub-paths. This is equivalent to `get_static_props` in NextJS.
159159
get_build_state: Option<GetBuildStateFn>,
@@ -183,7 +183,7 @@ impl<G: GenericNode> Template<G> {
183183
// Unlike `template`, this may not be set at all (especially in very simple apps)
184184
head: Rc::new(|_: Option<String>| sycamore::template! {}),
185185
get_build_paths: None,
186-
incremental_path_rendering: false,
186+
incremental_generation: false,
187187
get_build_state: None,
188188
get_request_state: None,
189189
should_revalidate: None,
@@ -353,7 +353,7 @@ impl<G: GenericNode> Template<G> {
353353
}
354354
/// Checks if this template can render more templates beyond those paths it explicitly defines.
355355
pub fn uses_incremental(&self) -> bool {
356-
self.incremental_path_rendering
356+
self.incremental_generation
357357
}
358358
/// Checks if this template is a template to generate paths beneath it.
359359
pub fn uses_build_paths(&self) -> bool {
@@ -396,9 +396,9 @@ impl<G: GenericNode> Template<G> {
396396
self.get_build_paths = Some(val);
397397
self
398398
}
399-
/// Enables the *incremental generation* strategy with the given function.
400-
pub fn incremental_path_rendering(mut self, val: bool) -> Template<G> {
401-
self.incremental_path_rendering = val;
399+
/// Enables the *incremental generation* strategy.
400+
pub fn incremental_generation(mut self) -> Template<G> {
401+
self.incremental_generation = true;
402402
self
403403
}
404404
/// Enables the *build state* strategy with the given function.

0 commit comments

Comments
 (0)