mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-06-06 02:31:16 +02:00
add tag feed
This commit is contained in:
44
lumina/app/tag/[tag]/page.tsx
Normal file
44
lumina/app/tag/[tag]/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
'use client';
|
||||
|
||||
import Head from "next/head";
|
||||
import { NostrProvider } from "nostr-react";
|
||||
import ProfileInfoCard from "@/components/ProfileInfoCard";
|
||||
import ProfileFeed from "@/components/ProfileFeed";
|
||||
import { useParams } from 'next/navigation'
|
||||
import { nip19 } from "nostr-tools";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||
import { SectionIcon, GridIcon } from '@radix-ui/react-icons'
|
||||
import TagFeed from "@/components/TagFeed";
|
||||
|
||||
const relayUrls = [
|
||||
"wss://relay.damus.io",
|
||||
"wss://relay.nostr.band",
|
||||
];
|
||||
|
||||
export default function Home() {
|
||||
|
||||
const params = useParams()
|
||||
let tag = params.tag
|
||||
// check if pubkey contains "npub"
|
||||
// if so, then we need to convert it to a pubkey
|
||||
// if (pubkey.includes("npub")) {
|
||||
// // convert npub to pubkey
|
||||
// pubkey = nip19.decode(pubkey.toString()).data.toString()
|
||||
// }
|
||||
|
||||
return (
|
||||
<>
|
||||
<NostrProvider relayUrls={relayUrls}>
|
||||
<Head>
|
||||
<title>LUMINA.rocks - {tag}</title>
|
||||
<meta name="description" content="Yet another nostr web ui" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
<div className="py-6 px-6">
|
||||
<TagFeed tag={tag.toString()} />
|
||||
</div>
|
||||
</NostrProvider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
44
lumina/components/TagFeed.tsx
Normal file
44
lumina/components/TagFeed.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useRef } from "react";
|
||||
import { useNostrEvents, dateToUnix } from "nostr-react";
|
||||
import NoteCard from './NoteCard';
|
||||
|
||||
interface TagFeedProps {
|
||||
tag: string;
|
||||
}
|
||||
|
||||
const TagFeed: React.FC<TagFeedProps> = ({tag}) => {
|
||||
const now = useRef(new Date()); // Make sure current time isn't re-rendered
|
||||
|
||||
const { events } = useNostrEvents({
|
||||
filter: {
|
||||
// since: dateToUnix(now.current), // all new events from now
|
||||
// since: 0,
|
||||
// limit: 100,
|
||||
kinds: [1],
|
||||
"#t": [tag],
|
||||
},
|
||||
});
|
||||
|
||||
// const filteredEvents = events.filter((event) => event.content.includes(".jpg"));
|
||||
// filter events with regex that checks for png, jpg, or gif
|
||||
let filteredEvents = events.filter((event) => event.content.match(/https?:\/\/.*\.(?:png|jpg|gif)/g)?.[0]);
|
||||
|
||||
// now filter all events with a tag[0] == t and tag[1] == nsfw
|
||||
filteredEvents = filteredEvents.filter((event) => event.tags.map((tag) => tag[0] == "t" && tag[1] == "nsfw"));
|
||||
// filter out all replies
|
||||
// filteredEvents = filteredEvents.filter((event) => !event.tags.some((tag) => { return tag[0] == 'e' }));
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2>Tag Feed for {tag}</h2>
|
||||
{filteredEvents.map((event) => (
|
||||
// <p key={event.id}>{event.pubkey} posted: {event.content}</p>
|
||||
<div key={event.id} className="py-6">
|
||||
<NoteCard key={event.id} pubkey={event.pubkey} text={event.content} eventId={event.id} tags={event.tags} event={event} />
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default TagFeed;
|
||||
Reference in New Issue
Block a user