diff --git a/pgml-dashboard/src/components/layouts/head/mod.rs b/pgml-dashboard/src/components/layouts/head/mod.rs index 1111815ad..f64e907c7 100644 --- a/pgml-dashboard/src/components/layouts/head/mod.rs +++ b/pgml-dashboard/src/components/layouts/head/mod.rs @@ -1,4 +1,4 @@ -use pgml_components::component; +use pgml_components::{component, Component}; use sailfish::TemplateOnce; #[derive(TemplateOnce, Default, Clone)] @@ -10,6 +10,7 @@ pub struct Head { pub preloads: Vec, pub context: Option, pub canonical: Option, + pub additional_components: Vec, } impl Head { @@ -58,6 +59,25 @@ impl Head { self.context = context.to_owned(); self } + + /// Add a component to ``. + /// + /// This can be anything, e.g. a `")); + /// ``` + /// + pub fn add_component(mut self, component: Component) -> Self { + self.additional_components.push(component); + self + } } component!(Head); diff --git a/pgml-dashboard/src/components/layouts/head/template.html b/pgml-dashboard/src/components/layouts/head/template.html index 3ad5d44a9..823dbb80a 100644 --- a/pgml-dashboard/src/components/layouts/head/template.html +++ b/pgml-dashboard/src/components/layouts/head/template.html @@ -97,4 +97,8 @@ }; <% } %> + + <% for component in additional_components { %> + <%+ component %> + <% } %> diff --git a/pgml-dashboard/src/components/layouts/marketing/base/mod.rs b/pgml-dashboard/src/components/layouts/marketing/base/mod.rs index 5d1ee0d36..15d983756 100644 --- a/pgml-dashboard/src/components/layouts/marketing/base/mod.rs +++ b/pgml-dashboard/src/components/layouts/marketing/base/mod.rs @@ -3,7 +3,7 @@ use crate::components::notifications::marketing::AlertBanner; use crate::guards::Cluster; use crate::models::User; use crate::Notification; -use pgml_components::component; +use pgml_components::{component, Component}; use sailfish::TemplateOnce; use std::fmt; @@ -72,6 +72,15 @@ impl Base { rsp } + /// Add a component to the ``. + /// + /// See [`Head::add_component`](crate::components::layouts::Head::add_component) for more information. + /// + pub fn add_head_component(mut self, component: Component) -> Self { + self.head = self.head.add_component(component); + self + } + pub fn footer(mut self, footer: String) -> Self { self.footer = Some(footer); self diff --git a/pgml-dashboard/src/templates/mod.rs b/pgml-dashboard/src/templates/mod.rs index 39a614f85..d6328661e 100644 --- a/pgml-dashboard/src/templates/mod.rs +++ b/pgml-dashboard/src/templates/mod.rs @@ -163,6 +163,17 @@ impl<'a> WebAppBase<'a> { self } + /// Add a component to head (``). + /// + /// # Arguments + /// + /// * `component` - The component to add to the head. + /// + pub fn add_head_component(&mut self, component: Component) -> &mut Self { + self.head = self.head.clone().add_component(component); + self + } + pub fn render(&mut self, template: T) -> String where T: sailfish::TemplateOnce, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy