Add preview feature for social media sharing#293
Conversation
Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
|
@copilot we cant add an env var called NEXT_PUBLIC_BASE_URL, we have to get from current browser. like some email do. |
…pen Graph metadata Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
Fixed in commit |
|
@copilot add translations for all languages |
Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
Added in commit |
|
@copilot if the s/[shareAlias] has an image and its public, this image turns the og:image? or just the app logo? |
Currently, it only uses the app logo. The metadata endpoint returns basic info (name, description, file count) but doesn't include file images. To use a share's image as og:image, we'd need to:
Would you like me to implement this enhancement? |
🎨 Add Social Media Preview with Open Graph Metadata
This PR implements Open Graph and Twitter Card metadata for share links, making them more friendly and less intimidating when shared on social media platforms.
📸 Preview
✨ Features
/s/[alias]) and reverse shares (/r/[alias])🔧 Changes
Backend (Server)
GET /shares/alias/:alias/metadataendpoint for lightweight share metadataGET /reverse-shares/alias/:alias/metadataendpoint for reverse share metadataFrontend (Web)
/s/[alias]/layout.tsxwith dynamicgenerateMetadatafunction/r/[alias]/layout.tsxwith dynamicgenerateMetadatafunctionx-forwarded-proto,x-forwarded-host,host) similar to email link generationGenerated Meta Tags Example
For a share with 5 files named "Project Files - December 2024":
📝 Configuration
Only the API base URL is needed in your
.envfile:# API base URL for server-side metadata fetching API_BASE_URL=http://localhost:3333No additional configuration required! The base URL for Open Graph metadata is automatically constructed from incoming request headers, ensuring it works correctly across all environments (localhost, staging, production) without manual configuration.
🧪 Testing
Test your share links on social media platforms using:
🔒 Privacy & Security
📦 Files Changed
Server:
apps/server/src/modules/share/controller.tsapps/server/src/modules/share/service.tsapps/server/src/modules/share/repository.tsapps/server/src/modules/share/routes.tsapps/server/src/modules/reverse-share/controller.tsapps/server/src/modules/reverse-share/service.tsapps/server/src/modules/reverse-share/routes.tsWeb:
apps/web/src/app/(shares)/s/[alias]/layout.tsxapps/web/src/app/(shares)/r/[alias]/layout.tsxapps/web/messages/*.json(all 15 language files)✅ Validation
Resolves the feature request for social media preview when sharing links on platforms like Twitter, Facebook, LinkedIn, WhatsApp, etc.
Fixes #242
Original prompt
Fixes #242
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.