File size: 2,126 Bytes
1f122c3
9cea1bb
 
1f122c3
9cea1bb
761239a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f122c3
9cea1bb
 
 
 
1f122c3
9cea1bb
1f122c3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

import { AppQueryProps } from "@/types"

import { Main } from "./main"
import { getVideo } from "./server/actions/ai-tube-hf/getVideo"
import { Metadata, ResolvingMetadata } from "next"


export async function generateMetadata(
  { params, searchParams: { v: videoId } }: AppQueryProps,
  parent: ResolvingMetadata
): Promise<Metadata> {
  // read route params

  const metadataBase = new URL('https://huggingface.co./spaces/jbilcke-hf/ai-tube')

  if (!videoId) {
    return {
      title: `🍿 AI Tube`,
      metadataBase,
      openGraph: {
        type: "website",
        // url: "https://example.com",
        title: "AI Tube",
        description: "The first fully AI generated video platform",
        siteName: "🍿 AI Tube",

        videos: [],
        images: [],
      },
    }
  }

  try {
    const video = await getVideo({ videoId, neverThrow: true })

    if (!video) {
      throw new Error("Video not found")
    }

    return {
      title: `${video.label} - AI Tube`,
      metadataBase,
      openGraph: {
        type: "website",
        // url: "https://example.com",
        title: video.label || "", // put the video title here
        description: video.description || "", // put the vide description here
        siteName: "AI Tube",
  
        videos: [
          {
            "url": video.assetUrl
          }
        ],
        // images: ['/some-specific-page-image.jpg', ...previousImages],
      },
    }
  } catch (err) {
    return {
      title: "AI Tube - 404 Video Not Found",
      metadataBase,
      openGraph: {
        type: "website",
        // url: "https://example.com",
        title: "AI Tube - 404 Not Found", // put the video title here
        description: "", // put the vide description here
        siteName: "AI Tube",
  
        videos: [],
        images: [],
      },
    }
  }
}

// we have routes but on Hugging Face we don't see them
// so.. let's use the work around
export default async function Page({ searchParams: { v: videoId } }: AppQueryProps) {
  const video = await getVideo({ videoId, neverThrow: true })
  return (
    <Main video={video} />
  )
}