mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-18 03:32: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.
|
the custom embed's title.
|
||||||
|
|
||||||
#### `site_name`
|
|
||||||
|
|
||||||
the site name to use for the embed.
|
|
||||||
|
|
||||||
#### `description`
|
#### `description`
|
||||||
|
|
||||||
the embed's description. optional.
|
the embed's description. optional.
|
||||||
|
|
|
@ -68,8 +68,6 @@ impl<'r> ResourceTemplateData<'r> {
|
||||||
pub struct EmbedMetadata {
|
pub struct EmbedMetadata {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub site_name: String,
|
|
||||||
#[serde(default)]
|
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub image: Option<String>,
|
pub image: Option<String>,
|
||||||
|
@ -83,12 +81,8 @@ impl EmbedMetadata {
|
||||||
/// builds the embed html tags
|
/// builds the embed html tags
|
||||||
pub fn build(self, builder: &SiteBuilder) -> eyre::Result<String> {
|
pub fn build(self, builder: &SiteBuilder) -> eyre::Result<String> {
|
||||||
let mut s = format!(
|
let mut s = format!(
|
||||||
r#"<meta content="{}" property="og:title"><meta content="{}" property="og:url">"#,
|
r#"<meta content="{}" property="og:title"><meta content="{}" property="og:url"><meta content="{}" property="og:site_name">"#,
|
||||||
self.title, builder.site.config.base_url
|
self.title, builder.site.config.base_url, builder.site.config.title,
|
||||||
);
|
|
||||||
s = format!(
|
|
||||||
r#"{s}<meta content="{}" property="og:site_name">"#,
|
|
||||||
self.site_name
|
|
||||||
);
|
);
|
||||||
if let Some(description) = self.description {
|
if let Some(description) = self.description {
|
||||||
s = format!(r#"{s}<meta content="{description}" property="og:description">"#);
|
s = format!(r#"{s}<meta content="{description}" property="og:description">"#);
|
||||||
|
@ -261,7 +255,6 @@ impl ResourceBuilder {
|
||||||
title: Some(data.title.clone()),
|
title: Some(data.title.clone()),
|
||||||
embed: Some(EmbedMetadata {
|
embed: Some(EmbedMetadata {
|
||||||
title: data.title.clone(),
|
title: data.title.clone(),
|
||||||
site_name: builder.site.config.title.clone(),
|
|
||||||
description: data.desc.clone(),
|
description: data.desc.clone(),
|
||||||
image: if let Some(cdn_file) = &data.cdn_file {
|
image: if let Some(cdn_file) = &data.cdn_file {
|
||||||
Some(builder.site.config.cdn_url(cdn_file)?.to_string())
|
Some(builder.site.config.cdn_url(cdn_file)?.to_string())
|
||||||
|
|
Loading…
Add table
Reference in a new issue