Browse Source

expose static site generation in the launch builder and prelude

Evan Almloff 11 tháng trước cách đây
mục cha
commit
742721bfde

+ 14 - 0
packages/dioxus/src/launch.rs

@@ -94,6 +94,20 @@ impl LaunchBuilder {
         }
     }
 
+    /// Launch your static site generation application.
+    #[cfg(feature = "static-generation")]
+    #[cfg_attr(docsrs, doc(cfg(feature = "static-generation")))]
+    pub fn static_generation() -> LaunchBuilder<dioxus_static_site_generation::Config, SendContext>
+    {
+        LaunchBuilder {
+            launch_fn: |root, contexts, cfg| {
+                dioxus_static_site_generation::launch::launch(root, contexts, cfg)
+            },
+            contexts: Vec::new(),
+            platform_config: None,
+        }
+    }
+
     /// Launch your fullstack application.
     #[cfg(feature = "mobile")]
     #[cfg_attr(docsrs, doc(cfg(feature = "mobile")))]

+ 7 - 0
packages/dioxus/src/lib.rs

@@ -104,6 +104,13 @@ pub mod prelude {
     #[cfg_attr(docsrs, doc(cfg(feature = "fullstack")))]
     pub use dioxus_fullstack::prelude::*;
 
+    #[cfg(all(feature = "static-generation", not(feature = "fullstack")))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(feature = "static-generation", not(feature = "fullstack"))))
+    )]
+    pub use dioxus_static_site_generation::prelude::*;
+
     #[cfg(feature = "router")]
     #[cfg_attr(docsrs, doc(cfg(feature = "router")))]
     pub use dioxus_router;

+ 5 - 0
packages/static-generation/src/lib.rs

@@ -6,3 +6,8 @@ pub mod launch;
 
 #[cfg(feature = "server")]
 pub(crate) mod ssg;
+
+/// A prelude of commonly used items in static generation apps.
+pub mod prelude {
+    pub use dioxus_fullstack::prelude::*;
+}