Skip to content

Since 0.25.0

getPageMarkdown

Build the page Markdown of the item's page.

View Markdown
On this page

Builds the page Markdown of the item's page, the document served to agents in place of it. The item must declare page.

src/app/md/about/route.ts
const about = await aboutItem.getPageMarkdown();

Signature

@qino/cms
item.getPageMarkdown(): Promise<string>;

Returns

Promise<string>:

  • A frontmatter block: title, description on one line when there is one, and canonical, the item's page on siteUrl, each a quoted string.
  • # {title}, from the title field and falling back to the file name without its extension, then > {description} when the description field holds one, then the body without its own frontmatter.
  • No heading when the body opens with its own H1. The frontmatter block still holds the title and description.
  • Site-relative links and images made absolute on siteUrl, and MDX components replaced through page.markdownComponents.
  • The frontmatter block, the heading and the description only for a JSON item.

Item views can't filter, so it never resolves to null.

Throws

  • Item "<file>" has no page: declare it to get page Markdown and a Markdown URL.
  • A raw ENOENT error from Node when the file does not exist.
  • Validation, relation, augment, and component function errors. See Errors.

See also