mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-17 19:22:21 -08:00
automatically pull site name for embed metadata for #1
This commit is contained in:
parent
762344b5da
commit
1875cc9d5c
2 changed files with 2 additions and 13 deletions
|
@ -47,10 +47,6 @@ table containing the following fields:
|
|||
|
||||
the custom embed's title.
|
||||
|
||||
#### `site_name`
|
||||
|
||||
the site name to use for the embed.
|
||||
|
||||
#### `description`
|
||||
|
||||
the embed's description. optional.
|
||||
|
|
|
@ -68,8 +68,6 @@ impl<'r> ResourceTemplateData<'r> {
|
|||
pub struct EmbedMetadata {
|
||||
pub title: String,
|
||||
#[serde(default)]
|
||||
pub site_name: String,
|
||||
#[serde(default)]
|
||||
pub description: Option<String>,
|
||||
#[serde(default)]
|
||||
pub image: Option<String>,
|
||||
|
@ -83,12 +81,8 @@ impl EmbedMetadata {
|
|||
/// builds the embed html tags
|
||||
pub fn build(self, builder: &SiteBuilder) -> eyre::Result<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
|
||||
r#"<meta content="{}" property="og:title"><meta content="{}" property="og:url"><meta content="{}" property="og:site_name">"#,
|
||||
self.title, builder.site.config.base_url, builder.site.config.title,
|
||||
);
|
||||
if let Some(description) = self.description {
|
||||
s = format!(r#"{s}<meta content="{description}" property="og:description">"#);
|
||||
|
@ -261,7 +255,6 @@ impl ResourceBuilder {
|
|||
title: Some(data.title.clone()),
|
||||
embed: Some(EmbedMetadata {
|
||||
title: data.title.clone(),
|
||||
site_name: builder.site.config.title.clone(),
|
||||
description: data.desc.clone(),
|
||||
image: if let Some(cdn_file) = &data.cdn_file {
|
||||
Some(builder.site.config.cdn_url(cdn_file)?.to_string())
|
||||
|
|
Loading…
Add table
Reference in a new issue