mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 16:17:29 +00:00
Add experimental opengraph tags
This commit is contained in:
parent
fbe9583988
commit
ecdd37dd1b
@ -172,7 +172,8 @@ module.exports = [
|
|||||||
if (post.isVideo()) await post.fetchVideoURL()
|
if (post.isVideo()) await post.fetchVideoURL()
|
||||||
return render(200, "pug/post.pug", {
|
return render(200, "pug/post.pug", {
|
||||||
title: getPageTitle(post),
|
title: getPageTitle(post),
|
||||||
post
|
post,
|
||||||
|
website_origin: constants.website_origin
|
||||||
})
|
})
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error === constants.symbols.NOT_FOUND) {
|
if (error === constants.symbols.NOT_FOUND) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//- Needs title, post
|
//- Needs website_origin, title, post
|
||||||
|
|
||||||
include includes/post
|
include includes/post
|
||||||
|
|
||||||
@ -8,6 +8,33 @@ html
|
|||||||
title= title
|
title= title
|
||||||
include includes/head
|
include includes/head
|
||||||
script(type="module" src="/static/js/post_overlay.js")
|
script(type="module" src="/static/js/post_overlay.js")
|
||||||
|
meta(property="og:url" content=`${website_origin}/p/${post.data.shortcode}`)
|
||||||
|
meta(property="og:type" content="article")
|
||||||
|
meta(property="og:title" content=`Post by ${post.data.owner.full_name || post.data.owner.username}`)
|
||||||
|
- let description = ""
|
||||||
|
if post.getCaption()
|
||||||
|
- description = post.getCaption()
|
||||||
|
if post.children.length >= 2
|
||||||
|
if description
|
||||||
|
- description = `\n\n${description}`
|
||||||
|
- description = `Gallery of ${post.children.length} images.${description}`
|
||||||
|
if description
|
||||||
|
meta(property="og:description" content=description)
|
||||||
|
- let firstEntry = post.children[0]
|
||||||
|
if firstEntry.isVideo()
|
||||||
|
meta(property="og:video" content=`${website_origin}${firstEntry.getVideoUrlP()}`)
|
||||||
|
meta(property="og:video:type" content="video/mp4")
|
||||||
|
meta(property="og:video:width" content=firstEntry.data.dimensions.width)
|
||||||
|
meta(property="og:video:height" content=firstEntry.data.dimensions.height)
|
||||||
|
meta(property="og:video:alt" content=firstEntry.getAlt())
|
||||||
|
else
|
||||||
|
meta(property="og:image" content=`${website_origin}${firstEntry.getDisplayUrlP()}`)
|
||||||
|
meta(property="og:image:width" content=firstEntry.data.dimensions.width)
|
||||||
|
meta(property="og:image:height" content=firstEntry.data.dimensions.height)
|
||||||
|
meta(property="og:image:type" content="image/jpeg")
|
||||||
|
meta(property="og:image:alt" content=firstEntry.getAlt())
|
||||||
|
meta(property="og:site_name" content="Bibliogram")
|
||||||
|
|
||||||
body.post-page
|
body.post-page
|
||||||
main
|
main
|
||||||
+post(post, false)
|
+post(post, false)
|
||||||
|
@ -17,6 +17,17 @@ html
|
|||||||
include includes/head
|
include includes/head
|
||||||
script(src="/static/js/pagination.js" type="module")
|
script(src="/static/js/pagination.js" type="module")
|
||||||
script(src="/static/js/post_overlay.js" type="module")
|
script(src="/static/js/post_overlay.js" type="module")
|
||||||
|
meta(property="og:url" content=`${website_origin}/u/${user.data.username}`)
|
||||||
|
meta(property="og:type" content="profile")
|
||||||
|
meta(property="og:title" content=(user.data.full_name || user.data.username))
|
||||||
|
if user.data.biography
|
||||||
|
meta(property="og:description" content=user.data.biography)
|
||||||
|
meta(property="og:image" content=`${website_origin}${user.proxyProfilePicture}`)
|
||||||
|
meta(property="og:image:width" content=150)
|
||||||
|
meta(property="og:image:height" content=150)
|
||||||
|
meta(property="og:image:type" content="image/jpeg")
|
||||||
|
meta(property="og:site_name" content="Bibliogram")
|
||||||
|
|
||||||
body
|
body
|
||||||
.main-divider
|
.main-divider
|
||||||
header.profile-overview
|
header.profile-overview
|
||||||
|
Loading…
Reference in New Issue
Block a user