add url to Blog, this seems useful.

This commit is contained in:
Igor Galić 2019-05-31 23:18:29 +02:00 committed by Igor Galić
parent 8e7f789969
commit 9cee38ae6a
Signed by untrusted user: igalic
GPG key ID: ACFEFF7F6A123A86
2 changed files with 15 additions and 2 deletions

View file

@ -327,6 +327,19 @@ impl Blog {
})
}
pub fn url(&self) -> String {
format!(
"https://{}",
self.custom_domain
.clone()
.unwrap_or_else(|| Host::new(format!(
"{}/~/{}",
Instance::get_local().unwrap().public_domain,
self.title
)))
)
}
pub fn icon_url(&self, conn: &Connection) -> String {
self.icon_id
.and_then(|id| Media::get(conn, id).and_then(|m| m.url()).ok())

View file

@ -13,8 +13,8 @@
<meta content="120" property="og:image:width" />
<meta content="120" property="og:image:height" />
<meta content="summary" property="twitter:card" />
<meta content="'@Instance::get_local().unwrap().name" property="og:site_name" />
<meta content="@blog.ap_url" property="og:url" />
<meta content="@Instance::get_local().unwrap().name" property="og:site_name" />
<meta content="@blog.url()" property="og:url" />
<meta content="@blog.fqn" property="profile:username" />
<meta content="@blog.title" property="og:title" />
<meta content="@blog.summary_html" name="description">