Nostr. Event. Article
(Nostr Lib v0.2.1)
(event)
(nip23)
(nip36)
View Source
Long-form content (Kind 30023 for published, Kind 30024 for drafts).
Implements NIP-23: https://github.com/nostr-protocol/nips/blob/master/23.md
Articles are addressable events containing Markdown content with optional metadata like title, summary, image, and publication date. Also supports NIP-36 content warnings.
Examples
# Create a published article
Article.create("# My Article\n\nContent here...", "my-article",
title: "My Article",
summary: "A brief description",
image: "https://example.com/image.jpg",
hashtags: ["nostr", "tutorial"]
)
# Create a draft
Article.create_draft("Work in progress...", "draft-article",
title: "Draft Title"
)
# Publish a draft
Article.publish(draft_article)See:
Summary
Functions
Returns the article's address coordinates for use in a tags.
Creates a published article (kind 30023).
Creates a draft article (kind 30024).
Returns true if this is a draft article.
Parses a kind 30023 or 30024 event into an Article struct.
Converts a draft article to a published article (kind 30024 -> 30023).
Types
Addressable event reference from a tag
Event reference from e tag
@type t() :: %Nostr.Event.Article{ addr_refs: [addr_ref()], content: binary(), content_warning: Nostr.NIP36.warning(), draft?: boolean(), event: Nostr.Event.t(), event_refs: [event_ref()], hashtags: [binary()], identifier: binary(), image: binary() | nil, published_at: DateTime.t() | nil, summary: binary() | nil, title: binary() | nil }
Functions
Returns the article's address coordinates for use in a tags.
Format: 30023:<pubkey>:<identifier> or 30024:<pubkey>:<identifier>
Creates a published article (kind 30023).
Options
:title- Article title:image- URL to header image:summary- Brief description:published_at- DateTime of first publication (defaults to now):hashtags- List of topic hashtags:event_refs- List of referenced event IDs or{id, relay}tuples:addr_refs- List of referenced addressable event coordinates or{coord, relay}tuples:content_warning- NIP-36 content warning (string reason ortruefor no reason)
Examples
Article.create("# Hello\n\nWorld", "hello-world", title: "Hello")
Article.create("Sensitive content", "nsfw-article", content_warning: "NSFW")
Creates a draft article (kind 30024).
Takes the same options as create/3.
Returns true if this is a draft article.
@spec parse(Nostr.Event.t()) :: t() | {:error, String.t(), Nostr.Event.t()}
Parses a kind 30023 or 30024 event into an Article struct.
Converts a draft article to a published article (kind 30024 -> 30023).
Sets published_at to the current time if not already set.