Browse Source

implemented 30817

imwald
Silberengel 5 months ago
parent
commit
91fc85b645
  1. 2
      src/components/Note/MarkdownArticle/MarkdownArticle.tsx
  2. 9
      src/components/Note/PublicationIndex/PublicationIndex.tsx
  3. 11
      src/components/Note/index.tsx
  4. 4
      src/components/Profile/ProfileArticles.tsx
  5. 2
      src/constants.ts
  6. 7
      src/lib/markup-detection.ts

2
src/components/Note/MarkdownArticle/MarkdownArticle.tsx

@ -505,7 +505,7 @@ export default function MarkdownArticle({
</div> </div>
)} )}
{/* Image Carousel - Only show for article content (30023, 30041, 30818) */} {/* Image Carousel - Only show for article content (30023, 30041, 30817, 30818) */}
{showImageGallery && allImages.length > 0 && ( {showImageGallery && allImages.length > 0 && (
<Collapsible open={isImagesOpen} onOpenChange={setIsImagesOpen} className="mt-8"> <Collapsible open={isImagesOpen} onOpenChange={setIsImagesOpen} className="mt-8">
<CollapsibleTrigger asChild> <CollapsibleTrigger asChild>

9
src/components/Note/PublicationIndex/PublicationIndex.tsx

@ -3,6 +3,7 @@ import { Event } from 'nostr-tools'
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import AsciidocArticle from '../AsciidocArticle/AsciidocArticle' import AsciidocArticle from '../AsciidocArticle/AsciidocArticle'
import MarkdownArticle from '../MarkdownArticle/MarkdownArticle'
import { generateBech32IdFromATag } from '@/lib/tag' import { generateBech32IdFromATag } from '@/lib/tag'
import client from '@/services/client.service' import client from '@/services/client.service'
import logger from '@/lib/logger' import logger from '@/lib/logger'
@ -109,6 +110,7 @@ export default function PublicationIndex({
if (!isNaN(kind) && kind === ExtendedKind.PUBLICATION_CONTENT || if (!isNaN(kind) && kind === ExtendedKind.PUBLICATION_CONTENT ||
kind === ExtendedKind.WIKI_ARTICLE || kind === ExtendedKind.WIKI_ARTICLE ||
kind === ExtendedKind.WIKI_ARTICLE_MARKDOWN ||
kind === ExtendedKind.PUBLICATION) { kind === ExtendedKind.PUBLICATION) {
// For this simplified version, we'll just extract the title from the coordinate // For this simplified version, we'll just extract the title from the coordinate
const nestedTitle = identifier || 'Untitled' const nestedTitle = identifier || 'Untitled'
@ -416,6 +418,13 @@ export default function PublicationIndex({
<AsciidocArticle event={ref.event} hideImagesAndInfo={true} /> <AsciidocArticle event={ref.event} hideImagesAndInfo={true} />
</div> </div>
) )
} else if (ref.kind === ExtendedKind.WIKI_ARTICLE_MARKDOWN) {
// Render 30817 content as MarkdownArticle
return (
<div key={index} id={sectionId} className="scroll-mt-4">
<MarkdownArticle event={ref.event} showImageGallery={false} />
</div>
)
} else { } else {
// Fallback for other kinds - just show a placeholder // Fallback for other kinds - just show a placeholder
return ( return (

11
src/components/Note/index.tsx

@ -106,6 +106,12 @@ export default function Note({
) : ( ) : (
<WikiCard className="mt-2" event={event} /> <WikiCard className="mt-2" event={event} />
) )
} else if (event.kind === ExtendedKind.WIKI_ARTICLE_MARKDOWN) {
content = showFull ? (
<MarkdownArticle className="mt-2" event={event} showImageGallery={true} />
) : (
<WikiCard className="mt-2" event={event} />
)
} else if (event.kind === ExtendedKind.PUBLICATION) { } else if (event.kind === ExtendedKind.PUBLICATION) {
content = showFull ? ( content = showFull ? (
<PublicationIndex className="mt-2" event={event} /> <PublicationIndex className="mt-2" event={event} />
@ -160,10 +166,11 @@ export default function Note({
content = <Zap className="mt-2" event={event} /> content = <Zap className="mt-2" event={event} />
} else { } else {
// Use MarkdownArticle for all other kinds // Use MarkdownArticle for all other kinds
// Only 30023, 30041, and 30818 will show image gallery and article info // Only 30023, 30041, 30817, and 30818 will show image gallery and article info
const showImageGallery = event.kind === kinds.LongFormArticle || const showImageGallery = event.kind === kinds.LongFormArticle ||
event.kind === ExtendedKind.PUBLICATION_CONTENT || event.kind === ExtendedKind.PUBLICATION_CONTENT ||
event.kind === ExtendedKind.WIKI_ARTICLE event.kind === ExtendedKind.WIKI_ARTICLE ||
event.kind === ExtendedKind.WIKI_ARTICLE_MARKDOWN
content = <MarkdownArticle className="mt-2" event={event} showImageGallery={showImageGallery} /> content = <MarkdownArticle className="mt-2" event={event} showImageGallery={showImageGallery} />
} }

4
src/components/Profile/ProfileArticles.tsx

@ -80,10 +80,10 @@ const ProfileArticles = forwardRef<{ refresh: () => void }, ProfileArticlesProps
const comprehensiveRelays = await buildComprehensiveRelayList() const comprehensiveRelays = await buildComprehensiveRelayList()
console.log('[ProfileArticles] Using comprehensive relay list:', comprehensiveRelays.length, 'relays') console.log('[ProfileArticles] Using comprehensive relay list:', comprehensiveRelays.length, 'relays')
// Fetch longform articles (kind 30023), wiki articles (kind 30818), publications (kind 30040), and highlights (kind 9802) // Fetch longform articles (kind 30023), wiki articles (kinds 30817, 30818), publications (kind 30040), and highlights (kind 9802)
const allEvents = await client.fetchEvents(comprehensiveRelays, { const allEvents = await client.fetchEvents(comprehensiveRelays, {
authors: [pubkey], authors: [pubkey],
kinds: [kinds.LongFormArticle, 30818, 30040, kinds.Highlights], // LongFormArticle, WikiArticle, Publication, and Highlights kinds: [kinds.LongFormArticle, 30817, 30818, 30040, kinds.Highlights], // LongFormArticle, WikiArticle (markdown), WikiArticle (asciidoc), Publication, and Highlights
limit: 100 limit: 100
}) })

2
src/constants.ts

@ -137,6 +137,7 @@ export const ExtendedKind = {
ZAP_RECEIPT: 9735, ZAP_RECEIPT: 9735,
PUBLICATION: 30040, PUBLICATION: 30040,
WIKI_ARTICLE: 30818, WIKI_ARTICLE: 30818,
WIKI_ARTICLE_MARKDOWN: 30817,
PUBLICATION_CONTENT: 30041, PUBLICATION_CONTENT: 30041,
// NIP-89 Application Handlers // NIP-89 Application Handlers
APPLICATION_HANDLER_RECOMMENDATION: 31989, APPLICATION_HANDLER_RECOMMENDATION: 31989,
@ -161,6 +162,7 @@ export const SUPPORTED_KINDS = [
ExtendedKind.ZAP_RECEIPT, ExtendedKind.ZAP_RECEIPT,
ExtendedKind.PUBLICATION, ExtendedKind.PUBLICATION,
ExtendedKind.WIKI_ARTICLE, ExtendedKind.WIKI_ARTICLE,
ExtendedKind.WIKI_ARTICLE_MARKDOWN,
ExtendedKind.PUBLICATION_CONTENT, ExtendedKind.PUBLICATION_CONTENT,
// NIP-89 Application Handlers // NIP-89 Application Handlers
ExtendedKind.APPLICATION_HANDLER_RECOMMENDATION, ExtendedKind.APPLICATION_HANDLER_RECOMMENDATION,

7
src/lib/markup-detection.ts

@ -8,11 +8,16 @@ export type MarkupType = 'asciidoc' | 'advanced-markdown' | 'basic-markdown' | '
* Detect the type of markup used in content * Detect the type of markup used in content
*/ */
export function detectMarkupType(content: string, eventKind?: number): MarkupType { export function detectMarkupType(content: string, eventKind?: number): MarkupType {
// Publications and wikis use AsciiDoc // Publications and wiki articles (30818) use AsciiDoc
if (eventKind === 30041 || eventKind === 30818) { if (eventKind === 30041 || eventKind === 30818) {
return 'asciidoc' return 'asciidoc'
} }
// Wiki articles (30817) use markdown
if (eventKind === 30817) {
return 'advanced-markdown'
}
// Long Form Articles (kind 30023) should use markdown detection // Long Form Articles (kind 30023) should use markdown detection
if (eventKind === 30023) { if (eventKind === 30023) {
// Force markdown detection for long form articles // Force markdown detection for long form articles

Loading…
Cancel
Save