From 55398150e02dd4bf75417e0a71b7416d4ed8f2b1 Mon Sep 17 00:00:00 2001 From: zoomiti Date: Fri, 9 Feb 2024 13:09:33 -0700 Subject: [PATCH 1/2] feat: use cdn url for static assets (#2281) --- integrations/utils/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/integrations/utils/src/lib.rs b/integrations/utils/src/lib.rs index 702e18fcc7..4b6733e9d7 100644 --- a/integrations/utils/src/lib.rs +++ b/integrations/utils/src/lib.rs @@ -55,7 +55,9 @@ pub fn html_parts_separated( options: &LeptosOptions, meta: Option<&MetaContext>, ) -> (String, &'static str) { - let pkg_path = &options.site_pkg_dir; + let pkg_path = option_env!("CDN_PKG_PATH") + .map(String::from) + .unwrap_or(format!("/{}", options.site_pkg_dir)); let output_name = &options.output_name; let nonce = use_nonce(); let nonce = nonce @@ -107,8 +109,8 @@ pub fn html_parts_separated( {head} - - + + From 0a23bf831be7b724acb0a88938094f20cb5614b4 Mon Sep 17 00:00:00 2001 From: zoomiti Date: Sat, 10 Feb 2024 22:45:34 -0700 Subject: [PATCH 2/2] fix: use Cow instead of `String::from` and use unwrap_or_else for CDN --- integrations/utils/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/utils/src/lib.rs b/integrations/utils/src/lib.rs index 4b6733e9d7..8039600220 100644 --- a/integrations/utils/src/lib.rs +++ b/integrations/utils/src/lib.rs @@ -2,6 +2,7 @@ use futures::{Stream, StreamExt}; use leptos::{nonce::use_nonce, use_context, RuntimeId}; use leptos_config::LeptosOptions; use leptos_meta::MetaContext; +use std::borrow::Cow; extern crate tracing; @@ -56,8 +57,8 @@ pub fn html_parts_separated( meta: Option<&MetaContext>, ) -> (String, &'static str) { let pkg_path = option_env!("CDN_PKG_PATH") - .map(String::from) - .unwrap_or(format!("/{}", options.site_pkg_dir)); + .map(Cow::from) + .unwrap_or_else(|| format!("/{}", options.site_pkg_dir).into()); let output_name = &options.output_name; let nonce = use_nonce(); let nonce = nonce