summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/views/note.pug
diff options
context:
space:
mode:
authorAlex <alexwh@users.noreply.github.com>2023-07-21 10:40:30 +0100
committerGitHub <noreply@github.com>2023-07-21 09:40:30 +0000
commitb3358f0a8b7e64bb3cbe16b61c5fd9c91c538110 (patch)
tree02ad00b2f3be63bec68b74272b8533cb85b1dc4b /packages/backend/src/server/web/views/note.pug
parentperf(backend): use RSA 2048bit (diff)
downloadsharkey-b3358f0a8b7e64bb3cbe16b61c5fd9c91c538110.tar.gz
sharkey-b3358f0a8b7e64bb3cbe16b61c5fd9c91c538110.tar.bz2
sharkey-b3358f0a8b7e64bb3cbe16b61c5fd9c91c538110.zip
enhance: Add OGP data for notes with multiple images/videos (#11142)
* Add OGP data for notes with multiple images/videos * Update CHANGELOG.md * Update packages/backend/src/server/web/views/note.pug Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update packages/backend/src/server/web/views/note.pug Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> --------- Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Diffstat (limited to 'packages/backend/src/server/web/views/note.pug')
-rw-r--r--packages/backend/src/server/web/views/note.pug22
1 files changed, 12 insertions, 10 deletions
diff --git a/packages/backend/src/server/web/views/note.pug b/packages/backend/src/server/web/views/note.pug
index 98d0c9a789..9bc652b6a1 100644
--- a/packages/backend/src/server/web/views/note.pug
+++ b/packages/backend/src/server/web/views/note.pug
@@ -5,8 +5,8 @@ block vars
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
- const url = `${config.url}/notes/${note.id}`;
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
- - const image = (note.files || []).find(file => file.type.startsWith('image/') && !file.isSensitive)
- - const video = (note.files || []).find(file => file.type.startsWith('video/') && !file.isSensitive)
+ - const images = (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
+ - const videos = (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
block title
= `${title} | ${instanceName}`
@@ -19,15 +19,17 @@ block og
meta(property='og:title' content= title)
meta(property='og:description' content= summary)
meta(property='og:url' content= url)
- if video
- meta(property='og:video:url' content= video.url)
- meta(property='og:video:secure_url' content= video.url)
- meta(property='og:video:type' content= video.type)
- // FIXME: add width and height
- // FIXME: add embed player for Twitter
- if image
+ if videos.length
+ each video in videos
+ meta(property='og:video:url' content= video.url)
+ meta(property='og:video:secure_url' content= video.url)
+ meta(property='og:video:type' content= video.type)
+ // FIXME: add width and height
+ // FIXME: add embed player for Twitter
+ if images.length
meta(property='twitter:card' content='summary_large_image')
- meta(property='og:image' content= image.url)
+ each image in images
+ meta(property='og:image' content= image.url)
else
meta(property='twitter:card' content='summary')
meta(property='og:image' content= avatarUrl)