diff --git a/app/(app)/app/_sections/LiveStreaming.tsx b/app/(app)/app/_sections/LiveStreaming.tsx index f894365..67d9244 100644 --- a/app/(app)/app/_sections/LiveStreaming.tsx +++ b/app/(app)/app/_sections/LiveStreaming.tsx @@ -1,3 +1,4 @@ +"use client"; import { Section, SectionHeader, @@ -7,9 +8,28 @@ import { import LiveBadge from "@/components/Badges/LiveBadge"; import { Button } from "@/components/ui/button"; import { RiArrowRightLine } from "react-icons/ri"; -import VideoCard from "@/components/VideoCard"; +import VideoCard, { VideoCardLoading } from "@/components/VideoCard"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import Link from "next/link"; +import useEvents from "@/lib/hooks/useEvents"; +import { Event } from "nostr-tools"; +import KindLoading from "@/components/KindCard/loading"; +import { nip19 } from "nostr-tools"; +import { getTagValues, getTagsValues } from "@/lib/nostr/utils"; +import { NOTABLE_ACCOUNTS } from "@/constants"; +import { NDKKind } from "@nostr-dev-kit/ndk"; +import { uniqBy } from "ramda"; + export default function LiveStreamingSection() { + const { events } = useEvents({ + filter: { + kinds: [30311 as NDKKind], + // authors: NOTABLE_ACCOUNTS.map((a) => nip19.decode(a).data.toString()), + limit: 5, + }, + }); + + const processedEvents = uniqBy((e) => getTagValues("title", e.tags), events); const demo = [ { id: 1, @@ -54,13 +74,52 @@ export default function LiveStreamingSection() {
- {demo.map((item) => ( - - ))} + {processedEvents?.length > 3 ? ( + processedEvents + .filter((e) => !!getTagValues("summary", e.tags)) + .slice(0, 6) + .map((e, idx) => { + if (idx > 6) return null; + const event = e.rawEvent() as Event; + const image = getTagValues("image", event.tags) as string; + const title = getTagValues("title", event.tags) as string; + const starts = getTagValues("starts", event.tags) as string; + const tags = getTagsValues("t", event.tags) as string[]; + const total_participants = getTagValues( + "total_participants", + event.tags, + ) as string; + const status = getTagValues("status", event.tags) as + | "live" + | "planned" + | "ended"; + + return ( + + + + ); + }) + ) : ( + <> + + + + + + )}
diff --git a/app/(app)/article/[key]/@1/page.tsx b/app/(app)/article/[key]/@1/page.tsx new file mode 100644 index 0000000..881a86e --- /dev/null +++ b/app/(app)/article/[key]/@1/page.tsx @@ -0,0 +1,36 @@ +"use client"; +import { useEffect } from "react"; +import Article from "@/containers/Article"; +import { useNDK } from "@nostr-dev-kit/ndk-react"; +import { nip19 } from "nostr-tools"; +import Spinner from "@/components/spinner"; +import useEvents from "@/lib/hooks/useEvents"; +export default function ArticlePage({ + params: { key }, +}: { + params: { + key: string; + }; +}) { + const { ndk } = useNDK(); + const { data, type } = nip19.decode(key); + const { events } = useEvents({ + filter: + type === "note" + ? { + ids: [data.toString()], + limit: 1, + } + : {}, + }); + + if (events?.[0]) { + return
{events[0].id}
; + } + + return ( +
+ +
+ ); +} diff --git a/app/(app)/article/[naddr]/page.tsx b/app/(app)/article/[key]/@30023/page.tsx similarity index 89% rename from app/(app)/article/[naddr]/page.tsx rename to app/(app)/article/[key]/@30023/page.tsx index db0ab2c..68c2449 100644 --- a/app/(app)/article/[naddr]/page.tsx +++ b/app/(app)/article/[key]/@30023/page.tsx @@ -6,14 +6,14 @@ import { nip19 } from "nostr-tools"; import Spinner from "@/components/spinner"; import useEvents from "@/lib/hooks/useEvents"; export default function ArticlePage({ - params: { naddr }, + params: { key }, }: { params: { - naddr: string; + key: string; }; }) { const { ndk } = useNDK(); - const { data, type } = nip19.decode(naddr); + const { data, type } = nip19.decode(key); const { events } = useEvents({ filter: type === "naddr" diff --git a/app/(app)/article/[key]/@30311/layout.tsx b/app/(app)/article/[key]/@30311/layout.tsx new file mode 100644 index 0000000..5bee456 --- /dev/null +++ b/app/(app)/article/[key]/@30311/layout.tsx @@ -0,0 +1,54 @@ +"use client"; +import { ReactElement, ReactNode } from "react"; +import { Button } from "@/components/ui/button"; +import { RiCloseFill } from "react-icons/ri"; +import { Avatar, AvatarImage, AvatarFallback } from "@radix-ui/react-avatar"; +import { useRouter } from "next/navigation"; +import { getTagAllValues, getTagValues } from "@/lib/nostr/utils"; +import useProfile from "@/lib/hooks/useProfile"; +import { nip19 } from "nostr-tools"; +import { getNameToShow, getTwoLetters } from "@/lib/utils"; + +export default function Layout(props: { + children: ReactElement; + params: { key: string }; +}) { + const router = useRouter(); + const { data, type } = nip19.decode(props.params.key); + const pubkey = type === "nevent" ? data.author ?? "" : ""; + const { profile } = useProfile(pubkey); + const npub = nip19.npubEncode(pubkey); + return ( +
+
+
+ + + + {getTwoLetters({ profile, npub })} + + + + {getNameToShow({ profile, npub })} + +
+ +
+
+
{props.children}
+
+ ); +} diff --git a/app/(app)/article/[key]/@30311/page.tsx b/app/(app)/article/[key]/@30311/page.tsx new file mode 100644 index 0000000..d22e42a --- /dev/null +++ b/app/(app)/article/[key]/@30311/page.tsx @@ -0,0 +1,42 @@ +"use client"; +import { useEffect } from "react"; +import Article from "@/containers/Article"; +import { useNDK } from "@nostr-dev-kit/ndk-react"; +import { nip19, type Event } from "nostr-tools"; +import Spinner from "@/components/spinner"; +import useEvents from "@/lib/hooks/useEvents"; +import KindCard from "@/components/KindCard"; +export default function EventPage({ + params: { key }, +}: { + params: { + key: string; + }; +}) { + const { ndk } = useNDK(); + const { data, type } = nip19.decode(key); + const { events } = useEvents({ + filter: + type === "nevent" + ? { + ids: [data.id], + limit: 1, + } + : {}, + }); + + if (events?.[0]) { + const event = events[0].rawEvent() as Event; + return ( +
+ +
+ ); + } + + return ( +
+ +
+ ); +} diff --git a/app/(app)/article/[key]/@event/layout.tsx b/app/(app)/article/[key]/@event/layout.tsx new file mode 100644 index 0000000..5bee456 --- /dev/null +++ b/app/(app)/article/[key]/@event/layout.tsx @@ -0,0 +1,54 @@ +"use client"; +import { ReactElement, ReactNode } from "react"; +import { Button } from "@/components/ui/button"; +import { RiCloseFill } from "react-icons/ri"; +import { Avatar, AvatarImage, AvatarFallback } from "@radix-ui/react-avatar"; +import { useRouter } from "next/navigation"; +import { getTagAllValues, getTagValues } from "@/lib/nostr/utils"; +import useProfile from "@/lib/hooks/useProfile"; +import { nip19 } from "nostr-tools"; +import { getNameToShow, getTwoLetters } from "@/lib/utils"; + +export default function Layout(props: { + children: ReactElement; + params: { key: string }; +}) { + const router = useRouter(); + const { data, type } = nip19.decode(props.params.key); + const pubkey = type === "nevent" ? data.author ?? "" : ""; + const { profile } = useProfile(pubkey); + const npub = nip19.npubEncode(pubkey); + return ( +
+
+
+ + + + {getTwoLetters({ profile, npub })} + + + + {getNameToShow({ profile, npub })} + +
+ +
+
+
{props.children}
+
+ ); +} diff --git a/app/(app)/article/[key]/@event/page.tsx b/app/(app)/article/[key]/@event/page.tsx new file mode 100644 index 0000000..d22e42a --- /dev/null +++ b/app/(app)/article/[key]/@event/page.tsx @@ -0,0 +1,42 @@ +"use client"; +import { useEffect } from "react"; +import Article from "@/containers/Article"; +import { useNDK } from "@nostr-dev-kit/ndk-react"; +import { nip19, type Event } from "nostr-tools"; +import Spinner from "@/components/spinner"; +import useEvents from "@/lib/hooks/useEvents"; +import KindCard from "@/components/KindCard"; +export default function EventPage({ + params: { key }, +}: { + params: { + key: string; + }; +}) { + const { ndk } = useNDK(); + const { data, type } = nip19.decode(key); + const { events } = useEvents({ + filter: + type === "nevent" + ? { + ids: [data.id], + limit: 1, + } + : {}, + }); + + if (events?.[0]) { + const event = events[0].rawEvent() as Event; + return ( +
+ +
+ ); + } + + return ( +
+ +
+ ); +} diff --git a/app/(app)/article/[key]/layout.tsx b/app/(app)/article/[key]/layout.tsx new file mode 100644 index 0000000..179d567 --- /dev/null +++ b/app/(app)/article/[key]/layout.tsx @@ -0,0 +1,37 @@ +import { ReactElement, ReactNode } from "react"; +import { nip19 } from "nostr-tools"; +import { redirect } from "next/navigation"; +export default function ModalLayout(props: { + children: ReactElement; + "1": ReactNode; + "30023": ReactNode; + event: ReactNode; + params: { + key: string; + }; +}) { + const key = props.params.key; + const { data, type } = nip19.decode(key); + if (type === "naddr") { + return ( +
+ {props[30023]} +
+ ); + } else if (type === "note") { + return ( +
+ {props[1]} +
+ ); + } else if (type === "nevent") { + return ( +
+ {props.event} +
+ ); + } else if (type === "npub") { + return redirect(`/${key}`); + } + return redirect(`/app`); +} diff --git a/app/(app)/article/[naddr]/layout.tsx b/app/(app)/article/[naddr]/layout.tsx deleted file mode 100644 index f92d60d..0000000 --- a/app/(app)/article/[naddr]/layout.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { ReactElement } from "react"; - -export default function ModalLayout({ children }: { children: ReactElement }) { - return ( -
- {children} -
- ); -} diff --git a/bun.lockb b/bun.lockb index cc3693e..8b17af1 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/KindCard/1.tsx b/components/KindCard/1.tsx index 46b5fce..320e872 100644 --- a/components/KindCard/1.tsx +++ b/components/KindCard/1.tsx @@ -33,7 +33,7 @@ export default function Kind1(props: Event) { }, ]} > - + {!!r.length && ( diff --git a/components/KindCard/components/Container.tsx b/components/KindCard/components/Container.tsx index add44bd..742c646 100644 --- a/components/KindCard/components/Container.tsx +++ b/components/KindCard/components/Container.tsx @@ -39,12 +39,13 @@ export default function Container({ actionOptions = [], }: CreatorCardProps) { return ( - + {pubkey ? : }
- {!!createdAt && formatDate(new Date(createdAt * 1000), "MMM Do")} + {!!createdAt && + formatDate(new Date(createdAt * 1000), "MMM Do, h:m a")}