Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

refactor(web): use shared metadata on share page

Richie McIlroy6c254a8c8c56
diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx
index d126db52e..69073b883 100644
--- a/apps/web/app/s/[videoId]/page.tsx
+++ b/apps/web/app/s/[videoId]/page.tsx
@@ -53,7 +53,7 @@ import { resolveDefaultPlaybackSpeed } from "@/lib/playback-speed";
import * as EffectRuntime from "@/lib/server";
import { runPromise } from "@/lib/server";
import { getSharePageBranding } from "@/lib/share-branding";
-import { getSharePlayerUrl } from "@/lib/share-player-url";
+import { buildShareVideoMetadata } from "@/lib/share-video-metadata";
import {
isSocialCrawlerUserAgent,
SOCIAL_REFERRER_DOMAINS,
@@ -239,69 +239,13 @@ export async function generateMetadata(
}
: notFound(),
onSome: ([video]) => {
- const previewImageUrl = new URL(
- `/api/video/preview?videoId=${videoId}&fallback=og`,
- buildEnv.NEXT_PUBLIC_WEB_URL,
- ).toString();
- const ogImageUrl = new URL(
- `/api/video/og?videoId=${videoId}`,
- buildEnv.NEXT_PUBLIC_WEB_URL,
- ).toString();
- const playlistUrl = new URL(
- `/api/playlist?videoId=${video.id}`,
- buildEnv.NEXT_PUBLIC_WEB_URL,
- ).toString();
-
return {
- title: `${video.name} | Cap Recording`,
- description: "Watch this video on Cap",
- openGraph: {
- images: [
- {
- url: previewImageUrl,
- width: 480,
- height: 270,
- type: "image/gif",
- },
- {
- url: ogImageUrl,
- width: 1200,
- height: 630,
- },
- ],
- videos: [
- {
- url: playlistUrl,
- width: 1280,
- height: 720,
- type: "video/mp4",
- },
- ],
- },
- twitter: {
- card: "player",
- title: `${video.name} | Cap Recording`,
- description: "Watch this video on Cap",
- images: [
- {
- url: previewImageUrl,
- width: 480,
- height: 270,
- type: "image/gif",
- },
- {
- url: ogImageUrl,
- width: 1200,
- height: 630,
- },
- ],
- players: {
- playerUrl: getSharePlayerUrl(videoId),
- streamUrl: playlistUrl,
- width: 1280,
- height: 720,
- },
- },
+ ...buildShareVideoMetadata({
+ videoId,
+ name: video.name,
+ sourceType: video.source.type,
+ webUrl: buildEnv.NEXT_PUBLIC_WEB_URL,
+ }),
robots: canRenderSocialPreview
? "index, follow"
: "noindex, nofollow",
@@ -325,17 +269,6 @@ export async function generateMetadata(
height: 630,
},
],
- videos: [
- {
- url: new URL(
- `/api/playlist?videoId=${videoId}`,
- buildEnv.NEXT_PUBLIC_WEB_URL,
- ).toString(),
- width: 1280,
- height: 720,
- type: "video/mp4",
- },
- ],
},
robots: "noindex, nofollow",
}),