feat(share): add Open Graph preview for social media crawlers#3234
feat(share): add Open Graph preview for social media crawlers#3234HFO4 merged 3 commits intocloudreve:masterfrom
Conversation
Add middleware to intercept social media bot requests and return OG meta tags for share links, enabling rich previews on platforms like Facebook, Twitter, Discord, etc.
|
Subpath previews ( |
That's fine, only previews for root level is sufficient. |
|
Thanks a lot, this one looks much better. I also pushed changes to reuse some of existing service, and show file thumbnails for single shared file if possible. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| if t == types.FileTypeFile && s.Edges.File != nil { | ||
| res.Size = s.Edges.File.Size | ||
| } |
There was a problem hiding this comment.
File size may display as zero if edge not loaded
Medium Severity
The Size field in BuildShare is only populated when s.Edges.File != nil, which requires the file edge to be eagerly loaded via the LoadShareFile{} context key. If ShareInfoService doesn't set this key, the file edge won't be loaded, Size remains 0, and the OG preview description will incorrectly display "0 B" for all file shares instead of the actual file size.
Additional Locations (1)
|
Thanks a lot! |

Summary
Warning
Only respects group-level share access permission (Cloudreve Pro share-level permissions not supported).
Enable rich previews when sharing Cloudreve links on Discord, Twitter, Telegram, etc.
Clean rewrite of #3227.
Preview
{file_name}{size} · {owner}{folder_name}Folder · {owner}{site_name}{site_name}{site_name}Closes #3226
Note
Enable rich Open Graph previews for shared resources on social platforms.
middleware/SharePreviewto detect social media bots and render an OG HTML page for/s/:id(/:password)and/home?path=share:links, sourcing site settings/icons and share info without counting views; includes folder/file status, owner, file size, and thumbnail when availableSharePreviewin master router beforeFrontendFileHandlerand static gzip; sets appropriate headers and client redirectexplorer.Shareresponse withsize(for unlocked file shares) to support preview detailsinventory/share.goWritten by Cursor Bugbot for commit daba550. This will update automatically on new commits. Configure here.