Skip to content

Since 0.25.0

getMarkdownUrl

The Markdown URL of an entry page by slug, or of the index page without one.

View Markdown
On this page

Returns the absolute URL of a page's Markdown: the page's URL on siteUrl with .md appended. Use it in <link rel="alternate" type="text/markdown"> and Link headers. The collection must declare pages.

src/app/blog/[slug]/page.tsx
postCollection.getMarkdownUrl("hello-world"); // "https://example.com/blog/hello-world.md"
postCollection.getMarkdownUrl(); // "https://example.com/blog.md"

Signature

@qino/cms
collection.getMarkdownUrl(slug: Slug): string;
collection.getMarkdownUrl(): string;

Parameters

Returns

string: pages.entry with the slug in place of {slug}, or pages.index, joined to siteUrl.

  • A trailing / is dropped before .md, so /blog/hello/ gives /blog/hello.md.
  • A path of / gives /index.md.
  • Each slug segment is URL-encoded.

It reads no file, so it doesn't check that the entry exists.

Throws

  • Collection "<directory>" has no pages: declare them to get page Markdown and Markdown URLs.

See also