From 4e50073e079489e837644ba2531377382e6a65ce Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 15 Oct 2025 17:31:39 +0200 Subject: [PATCH] feat: update gateway config to use nostr.at and define ants.sh as search portal --- src/components/ContentPanel.tsx | 7 +++---- src/config/nostrGateways.ts | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index 5975ee8f..1576e14a 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -9,7 +9,7 @@ import 'prismjs/themes/prism-tomorrow.css' import { faSpinner, faCheckCircle, faEllipsisH, faExternalLinkAlt, faMobileAlt, faCopy, faShare, faSearch } from '@fortawesome/free-solid-svg-icons' import { ContentSkeleton } from './Skeletons' import { nip19 } from 'nostr-tools' -import { getNostrUrl } from '../config/nostrGateways' +import { getNostrUrl, getSearchUrl, SEARCH_PORTAL } from '../config/nostrGateways' import { RELAYS } from '../config/relays' import { RelayPool } from 'applesauce-relay' import { IAccount } from 'applesauce-accounts' @@ -346,7 +346,7 @@ const ContentPanel: React.FC = ({ const handleOpenSearch = () => { if (articleLinks) { - window.open(articleLinks.portal, '_blank', 'noopener,noreferrer') + window.open(getSearchUrl(articleLinks.naddr), '_blank', 'noopener,noreferrer') } setShowArticleMenu(false) } @@ -432,8 +432,7 @@ const ContentPanel: React.FC = ({ const handleSearchExternalUrl = () => { if (selectedUrl) { - const searchUrl = `https://ants.sh/?q=${encodeURIComponent(selectedUrl)}` - window.open(searchUrl, '_blank', 'noopener,noreferrer') + window.open(getSearchUrl(selectedUrl), '_blank', 'noopener,noreferrer') } setShowExternalMenu(false) } diff --git a/src/config/nostrGateways.ts b/src/config/nostrGateways.ts index 5316a6fd..e3357362 100644 --- a/src/config/nostrGateways.ts +++ b/src/config/nostrGateways.ts @@ -2,20 +2,21 @@ * Nostr gateway URLs for viewing events and profiles on the web */ -export const NOSTR_GATEWAY = 'https://ants.sh' as const +export const NOSTR_GATEWAY = 'https://nostr.at' as const +export const SEARCH_PORTAL = 'https://ants.sh' as const /** * Get a profile URL on the gateway */ export function getProfileUrl(npub: string): string { - return `${NOSTR_GATEWAY}/p/${npub}` + return `${NOSTR_GATEWAY}/${npub}` } /** * Get an event URL on the gateway */ export function getEventUrl(nevent: string): string { - return `${NOSTR_GATEWAY}/e/${nevent}` + return `${NOSTR_GATEWAY}/${nevent}` } /** @@ -23,12 +24,14 @@ export function getEventUrl(nevent: string): string { * Automatically detects if it's a profile (npub/nprofile) or event (note/nevent/naddr) */ export function getNostrUrl(identifier: string): string { - // Check the prefix to determine if it's a profile or event - if (identifier.startsWith('npub') || identifier.startsWith('nprofile')) { - return `${NOSTR_GATEWAY}/p/${identifier}` - } - - // Everything else (note, nevent, naddr) goes to /e/ - return `${NOSTR_GATEWAY}/e/${identifier}` + // nostr.at uses simple /{identifier} format for all types + return `${NOSTR_GATEWAY}/${identifier}` +} + +/** + * Get a search portal URL with a query + */ +export function getSearchUrl(query: string): string { + return `${SEARCH_PORTAL}/?q=${encodeURIComponent(query)}` }