extractMarkdownProps()function

extractMarkdownProps(text: string): { title: string | undefined; description: string | undefined }
ParamType
textstring
The markdown source string (a markdown file's text, or a JSDoc description). required
Return
{ title: string | undefined; description: string | undefined }
An object whose title and description are each a plain string, or undefined when absent.

Parse a markdown source string once and derive its title and description in a single pass.

  • title — plain text of the first # h1 heading, or undefined if there is none.
  • description — plain-text summary of the first prose paragraph, or undefined if there is none.
  • Both query the parsed markup tree, so inline syntax ( `code` , *emphasis*, links) resolves to clean plain text.

Examples

extractMarkdownProps("# Title\n\nSome intro.") // { title: "Title", description: "Some intro." }