Skip to content

title

Import from @varavel/vdl-plugin-sdk/utils/markdown.

function title(content): string;

Extracts the first Markdown heading from a document.

This helper is intended for lightweight metadata discovery when a full Markdown parser would be unnecessary. It returns the text content of the first heading-like line found in the document and provides a stable fallback when no heading is present.

The function is well suited for generators that need a document title for filenames, navigation labels, page metadata, or content indexes.

Parameters

Parameter Type Description
content string Markdown document content to inspect.

Returns

string

The first heading text, or "Untitled" when no heading is found.

Examples

title("# API Reference\n\nGenerated docs");
// "API Reference"
title("No heading here");
// "Untitled"