/// Exports your app to static files, which can be served from anywhere, without needing a server. This assumes that the app has already
/// been built, and that no templates are using non-static features (which can be ensured by passing `true` as the last parameter to
/// `build_app`).
Exports your app to static files, which can be served from anywhere, without needing a server. This assumes that the app has already
been built, and that no templates are using non-static features (which can be ensured by passing `true` as the last parameter to
`build_app`).
Exports your app to static files which can be served from anywhere without needing a server . This assumes that the app has already been built and that no templates are using non - static features ( which can be ensured by passing ` true ` as the last parameter to ` build_app ` ) .
pub async fn export_app(
    templates: &TemplateMap<SsrNode>,
    html_shell_path: &str,
    locales: &Locales,
    root_id: &str,
    immutable_store: &ImmutableStore,
    translations_manager: &impl TranslationsManager,
    path_prefix: String,
) -> Result<(), ServerError> {
    // The render configuration acts as a guide here, it tells us exactly what we need to iterate over (no request-side pages!)
    let render_cfg = get_render_cfg(immutable_store).await?;
    // Get the HTML shell and prepare it by interpolating necessary values
    let raw_html_shell =
        fs::read_to_string(html_shell_path).map_err(|err| BuildError::HtmlShellNotFound {
            path: html_shell_path.to_string(),
            source: err,
        })?;
    let html_shell = HtmlShell::new(raw_html_shell, root_id, &render_cfg, &path_prefix);
    // We can do literally everything concurrently here
    let mut export_futs = Vec::new();
    // Loop over every partial
    for (path, template_path) in render_cfg {
        let fut = export_path(
            (path.to_string(), template_path.to_string()),
            templates,
            locales,
            &html_shell,
            immutable_store,
            path_prefix.to_string(),
        );
        export_futs.push(fut);
    }
    // If we're using i18n, loop through the locales to create translations files
    let mut translations_futs = Vec::new();
    if locales.using_i18n {
        for locale in locales.get_all() {
            let fut = create_translation_file(locale, immutable_store, translations_manager);
            translations_futs.push(fut);
        }
    }
    try_join(try_join_all(export_futs), try_join_all(translations_futs)).await?;
    // Copying in bundles from the filesystem is left to the CLI command for exporting, so we're done!
    Ok(())
}
pub async fn export_app ( templates : & TemplateMap < SsrNode > , html_shell_path : & str , locales : & Locales , root_id : & str , immutable_store : & ImmutableStore , translations_manager : & impl TranslationsManager , path_prefix : String , ) -> Result < ( ) , ServerError > { // The render configuration acts as a guide here, it tells us exactly what we need to iterate over (no request-side pages!) let render_cfg = get_render_cfg ( immutable_store ) . await ? ; // Get the HTML shell and prepare it by interpolating necessary values let raw_html_shell = fs :: read_to_string ( html_shell_path ) . map_err ( | err | BuildError :: HtmlShellNotFound { path : html_shell_path . to_string ( ) , source : err , } ) ? ; let html_shell = HtmlShell :: new ( raw_html_shell , root_id , & render_cfg , & path_prefix ) ; // We can do literally everything concurrently here let mut export_futs = Vec :: new ( ) ; // Loop over every partial for ( path , template_path ) in render_cfg { let fut = export_path ( ( path . to_string ( ) , template_path . to_string ( ) ) , templates , locales , & html_shell , immutable_store , path_prefix . to_string ( ) , ) ; export_futs . push ( fut ) ; } // If we're using i18n, loop through the locales to create translations files let mut translations_futs = Vec :: new ( ) ; if locales . using_i18n { for locale in locales . get_all ( ) { let fut = create_translation_file ( locale , immutable_store , translations_manager ) ; translations_futs . push ( fut ) ; } } try_join ( try_join_all ( export_futs ) , try_join_all ( translations_futs ) ) . await ? ; // Copying in bundles from the filesystem is left to the CLI command for exporting, so we're done! Ok ( ( ) ) }
Exports your app to static files, which can be served from anywhere, without needing a server.
Exports your app to static files which can be served from anywhere without needing a server .
templates
&TemplateMap<SsrNode>
html_shell_path
&str
locales
&Locales
root_id
&str
immutable_store
&ImmutableStore
translations_manager
&impl TranslationsManager
path_prefix
String