mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
implement custom embeds for regular pages
This commit is contained in:
parent
9a0e8f4607
commit
6a395f2292
5 changed files with 28 additions and 6 deletions
|
@ -80,18 +80,24 @@ where
|
|||
}
|
||||
|
||||
/// struct for adding custom meta content embeds
|
||||
#[derive(Debug)]
|
||||
pub struct EmbedMetadata<'s> {
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct EmbedMetadata {
|
||||
pub title: String,
|
||||
pub site_name: &'s str,
|
||||
#[serde(default)]
|
||||
pub site_name: String,
|
||||
#[serde(default)]
|
||||
pub description: Option<String>,
|
||||
#[serde(default)]
|
||||
pub url: Option<String>,
|
||||
#[serde(default)]
|
||||
pub image: Option<String>,
|
||||
#[serde(default = "EmbedMetadata::default_theme_color")]
|
||||
pub theme_color: String,
|
||||
#[serde(default)]
|
||||
pub large_image: bool,
|
||||
}
|
||||
|
||||
impl<'s> EmbedMetadata<'s> {
|
||||
impl EmbedMetadata {
|
||||
/// builds the embed html tags
|
||||
pub fn build(self) -> String {
|
||||
let mut s = format!(r#"<meta content="{}" property="og:title">"#, self.title);
|
||||
|
@ -118,6 +124,10 @@ impl<'s> EmbedMetadata<'s> {
|
|||
|
||||
s
|
||||
}
|
||||
|
||||
fn default_theme_color() -> String {
|
||||
"rgb(255, 196, 252)".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue