mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-18 03:32:21 -08:00
autofill url field for #1
This commit is contained in:
parent
83c5f6038f
commit
d3f424f24f
2 changed files with 6 additions and 9 deletions
|
@ -289,7 +289,7 @@ impl SiteBuilder {
|
|||
|
||||
let head = page_metadata.embed.map(|mut embed| {
|
||||
embed.site_name.clone_from(&self.site.config.title);
|
||||
embed.build()
|
||||
embed.build(self)
|
||||
});
|
||||
|
||||
let out = self.tera.render(
|
||||
|
|
|
@ -72,8 +72,6 @@ pub struct EmbedMetadata {
|
|||
#[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,
|
||||
|
@ -83,8 +81,11 @@ pub struct EmbedMetadata {
|
|||
|
||||
impl EmbedMetadata {
|
||||
/// builds the embed html tags
|
||||
pub fn build(self) -> String {
|
||||
let mut s = format!(r#"<meta content="{}" property="og:title">"#, self.title);
|
||||
pub fn build(self, builder: &SiteBuilder) -> String {
|
||||
let mut s = format!(
|
||||
r#"<meta content="{}" property="og:title"><meta content="{}" property="og:url">"#,
|
||||
self.title, builder.site.config.base_url
|
||||
);
|
||||
s = format!(
|
||||
r#"{s}<meta content="{}" property="og:site_name">"#,
|
||||
self.site_name
|
||||
|
@ -92,9 +93,6 @@ impl EmbedMetadata {
|
|||
if let Some(description) = self.description {
|
||||
s = format!(r#"{s}<meta content="{description}" property="og:description">"#);
|
||||
}
|
||||
if let Some(url) = self.url {
|
||||
s = format!(r#"{s}<meta content="{url}" property="og:url">"#);
|
||||
}
|
||||
if let Some(image) = self.image {
|
||||
s = format!(r#"{s}<meta content="{image}" property="og:image">"#);
|
||||
}
|
||||
|
@ -267,7 +265,6 @@ impl ResourceBuilder {
|
|||
} else {
|
||||
None
|
||||
},
|
||||
url: None,
|
||||
theme_color: EmbedMetadata::default_theme_color(),
|
||||
large_image: true,
|
||||
}),
|
||||
|
|
Loading…
Add table
Reference in a new issue