add sorting by tags
This commit is contained in:
parent
1e1c675a7a
commit
42434a4486
4 changed files with 39 additions and 1 deletions
|
@ -16,6 +16,7 @@ import { getLoginKeys } from "./utils";
|
|||
import { useNostr } from "./context/NostrProvider";
|
||||
import Sniped from "./pages/Sniped";
|
||||
import { Loading } from "./components/Loading";
|
||||
import SnipByTag from "./pages/SnipByTag";
|
||||
|
||||
export default function App() {
|
||||
const [keypair, setKeypair] = useAtom("keypair");
|
||||
|
@ -41,6 +42,7 @@ export default function App() {
|
|||
<Routes>
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<Home />} />
|
||||
<Route path="lang/:lang" element={<SnipByTag />} />
|
||||
<Route path="about" element={<About />} />
|
||||
<Route path="profile?/:id" element={<Profile />} />
|
||||
<Route path="snip?/:id" element={<Sniped />} />
|
||||
|
|
|
@ -33,7 +33,11 @@ const Editor = () => {
|
|||
sendSignEvent({
|
||||
kind: 1,
|
||||
keypair,
|
||||
tags: [["t", TOPIC]],
|
||||
// tags: [["t", TOPIC]],
|
||||
tags: [
|
||||
["t", TOPIC],
|
||||
["l", mode],
|
||||
],
|
||||
content: JSON.stringify({ snip, mode, fileName }),
|
||||
publish,
|
||||
}).then(() => {
|
||||
|
|
|
@ -50,6 +50,8 @@ const Snip = ({ events }) => {
|
|||
{shortPubKey(data.pubkey, 7)}
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
<Link to={`/lang/${s.mode}`}>#{s.mode}</Link>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
|
30
src/pages/SnipByTag.jsx
Normal file
30
src/pages/SnipByTag.jsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { useParams } from "react-router-dom";
|
||||
import { Loading } from "../components/Loading";
|
||||
import Snip from "../components/Snip";
|
||||
import { TOPIC } from "../config";
|
||||
import { useNostrEvents } from "../context/NostrProvider";
|
||||
|
||||
const SnipByTag = () => {
|
||||
const { lang } = useParams();
|
||||
|
||||
const { events, isLoading } = useNostrEvents({
|
||||
filter: {
|
||||
// since: dateToUnix(now.current),
|
||||
// until: dateToUnix(now.current),
|
||||
kinds: [1],
|
||||
"#t": [TOPIC],
|
||||
"#l": [lang],
|
||||
limit: 100,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>#{lang}</h2>
|
||||
|
||||
{isLoading ? <Loading /> : <Snip events={events} />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SnipByTag;
|
Loading…
Add table
Add a link
Reference in a new issue