UNPKG

react-substack

Version:

Read any Substack newsletter with React

82 lines (79 loc) 1.89 kB
declare enum NodeType { PARAGRAPH = "paragraph", IMAGE = "image", HR = "hr", HEADING = "heading", LIST = "list", LI = "listitem", BLOCKQUOTE = "blockquote" } type ParagraphNode = { type: NodeType.PARAGRAPH; children: string; }; type ImageNode = { type: NodeType.IMAGE; caption?: string; src: string; }; type ListNode = { type: NodeType.LIST; ordered: boolean; items: ListItemNode[]; }; type ListItemNode = { type: NodeType.LI; children: BodyNode[]; }; type BlockquoteNode = { type: NodeType.BLOCKQUOTE; children: BodyNode[]; }; type HrNode = { type: NodeType.HR; }; type HeadingNode = { type: NodeType.HEADING; level: number; children: string; }; type BodyNode = ParagraphNode | BlockquoteNode | ImageNode | HrNode | HeadingNode | ListNode | ListItemNode; type PostBody = BodyNode[]; type Post = { pubdate: string; title: string; link: string; body: PostBody; bodyHTML: string; description?: string; cover?: string; author?: string; slug: string; }; type Substack = { url: string; subdomain: string; posts: Post[]; about: string; title: string; image: string; }; type UseSubstackValue = Partial<Substack> & { state: UseSubstackStates; error?: string; }; type UseSubstackStates = 'loading' | 'ready' | 'data' | 'error'; /** * Returns any substack newsletter as JSON */ declare const useSubstack: (subdomain: string) => UseSubstackValue; type UsePostValue = { state: UseSubstackStates; error?: string; post?: Post; }; /** * Returns a single post from a substack newsletter */ declare const usePost: (subdomain: string, slug: string) => UsePostValue; export { BlockquoteNode, BodyNode, HeadingNode, HrNode, ImageNode, ListItemNode, ListNode, NodeType, ParagraphNode, Post, PostBody, Substack, usePost, useSubstack };