Add NoteCard export, update dependencies, and integrate emoji-picker-react
- Exported `NoteCard` from `note.tsx` for reuse in other components. - Updated `package-lock.json` to add new dependencies including `emoji-picker-react`, `tailwindcss`, and `autoprefixer`.
This commit is contained in:
@@ -105,3 +105,5 @@ always use tanstack/router with web apps
|
||||
always use react query with web apps
|
||||
|
||||
always use bun for running scripts and building things
|
||||
|
||||
always use port 4000 for server listener addresses so they don't conflict with the one running on default 3000
|
||||
977
package-lock.json
generated
977
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@
|
||||
"@nostr-dev-kit/ndk": "^2.8.2",
|
||||
"@tanstack/react-query": "^5.56.2",
|
||||
"@tanstack/react-router": "^1.58.3",
|
||||
"emoji-picker-react": "^4.13.3",
|
||||
"nostr-tools": "^2.7.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
@@ -25,13 +26,13 @@
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"eslint-plugin-react-refresh": "^0.4.11",
|
||||
"typescript": "^5.6.2",
|
||||
"vite": "^5.4.6",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"postcss": "^8.4.47",
|
||||
"autoprefixer": "^10.4.20"
|
||||
"tailwindcss": "^3.4.13",
|
||||
"typescript": "^5.6.2",
|
||||
"vite": "^5.4.6"
|
||||
}
|
||||
}
|
||||
81
src/lib/event.ts
Normal file
81
src/lib/event.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { NDKEvent } from '@nostr-dev-kit/ndk'
|
||||
import { nip19 } from 'nostr-tools'
|
||||
|
||||
export function getParentETag(event?: NDKEvent) {
|
||||
if (!event) return undefined
|
||||
|
||||
// For kind 1 (short text notes), look for reply marker first
|
||||
if (event.kind === 1) {
|
||||
let tag = event.tags.find(([tagName, , , marker]: string[]) => {
|
||||
return tagName === 'e' && marker === 'reply'
|
||||
})
|
||||
if (!tag) {
|
||||
// Fallback to last e-tag that's not a mention
|
||||
const eTags = event.tags.filter(
|
||||
([tagName, tagValue, , marker]: string[]) =>
|
||||
tagName === 'e' &&
|
||||
!!tagValue &&
|
||||
marker !== 'mention'
|
||||
)
|
||||
tag = eTags[eTags.length - 1]
|
||||
}
|
||||
return tag
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function getParentEventHexId(event?: NDKEvent) {
|
||||
const tag = getParentETag(event)
|
||||
return tag?.[1]
|
||||
}
|
||||
|
||||
export function getParentBech32Id(event?: NDKEvent) {
|
||||
const eTag = getParentETag(event)
|
||||
if (!eTag) return undefined
|
||||
|
||||
try {
|
||||
const eventId = eTag[1]
|
||||
if (!eventId) return undefined
|
||||
return nip19.noteEncode(eventId)
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function getRootETag(event?: NDKEvent) {
|
||||
if (!event) return undefined
|
||||
|
||||
if (event.kind === 1) {
|
||||
let tag = event.tags.find(([tagName, , , marker]: string[]) => {
|
||||
return tagName === 'e' && marker === 'root'
|
||||
})
|
||||
if (!tag) {
|
||||
// Fallback to first e-tag
|
||||
tag = event.tags.find(
|
||||
([tagName, tagValue]: string[]) => tagName === 'e' && !!tagValue
|
||||
)
|
||||
}
|
||||
return tag
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function getRootEventHexId(event?: NDKEvent) {
|
||||
const tag = getRootETag(event)
|
||||
return tag?.[1]
|
||||
}
|
||||
|
||||
export function getRootBech32Id(event?: NDKEvent) {
|
||||
const eTag = getRootETag(event)
|
||||
if (!eTag) return undefined
|
||||
|
||||
try {
|
||||
const eventId = eTag[1]
|
||||
if (!eventId) return undefined
|
||||
return nip19.noteEncode(eventId)
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
1280
src/routes/index.tsx
1280
src/routes/index.tsx
File diff suppressed because it is too large
Load Diff
2
src/routes/note.tsx
Normal file
2
src/routes/note.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
export { NoteCard } from './index'
|
||||
export default undefined as unknown as typeof import('./index').NoteCard
|
||||
Reference in New Issue
Block a user