Skip to Content
API reference

API reference

The public surface is organized around defineCollection. Site-wide helpers (Organization JSON-LD, robots, sitemap composition) take a SiteConfig.

@next-md-blog/core

Site

  • defineSite(config: SiteConfig): SiteConfig — type-narrowing constructor with sensible defaults.
  • generateOrganizationSchema(site): Record<string, unknown> | undefined — full Organization JSON-LD (founder, foundingDate, address, contactPoint, wikidata in sameAs).
  • generateWebsiteSchema(site, opts?)WebSite + optional SearchAction.

Collections

  • defineCollection<T>(config: CollectionConfig<T>): Collection<T> — see Configuration for every field.

A Collection<T> exposes:

Data

  • getOne(slug, opts?): Promise<ContentDoc<T> | null>
  • getAll(opts?): Promise<ContentMetadata<T>[]> (sorted by frontmatter.date desc)
  • getAllSlugs(opts?): Promise<string[]>
  • getInAllLocales(slug, locales): Promise<Map<string, ContentDoc<T> | null>>

Queries

  • getByAuthor(authorSlug, opts?): Promise<ContentMetadata<T>[]>
  • getBySeries(seriesSlug, opts?): Promise<ContentMetadata<T>[]>
  • getAllAuthorSlugs(locales?): Promise<string[]>
  • getAllSeriesSlugs(locales?): Promise<string[]>

URLs

  • url(slug, locale?, canonicalUrl?): string
  • indexUrl(locale?): string
  • hreflangMap(slug, locales): Promise<Record<string, string>> — only locales with a translation.

SEO

  • metadata(doc, opts?): Promise<Metadata> — Next Metadata. opts.titleTemplate accepts 'site-suffix' (default), 'absolute', 'bare', or a function.
  • listMetadata(docs, opts?): Metadata — index/list page metadata.
  • schema(doc, opts?): Record<string, unknown> — single JSON-LD doc.
  • schemaGraph(doc, breadcrumbs?, opts?): Record<string, unknown>Organization + <doc schema> + BreadcrumbList @graph. opts.speakable: true adds default selectors; opts.extend mutates the doc node.
  • breadcrumbsSchema(doc, breadcrumbs?, opts?)BreadcrumbList JSON-LD.

Output

  • rssXml(opts?): Promise<string> — RSS 2.0 XML string.
  • rssResponse(opts?): Promise<NextResponse> — fully-wired Next response with Cache-Control.
  • sitemapEntries(opts: { locales }): Promise<MetadataRoute.Sitemap> — one row per slug, with xhtml:hreflang alternates for every locale that has a translation.
  • llmsTxtSection(opts: { locales, defaultLocale? }): Promise<string> — markdown section for llmstxt.org .
  • llmsFullTxtSection(opts: { locales }): Promise<string> — concatenated post bodies.

Composition

  • composeSitemap({ collections, locales, staticEntries? }): Promise<MetadataRoute.Sitemap> — merges static rows with every collection’s sitemap rows.
  • composeLlmsTxt({ site, collections, locales, defaultLocale?, summary? }): Promise<string> — site-wide llms.txt.
  • composeLlmsFullTxt({ site, collections, locales, summary? }): Promise<string>.

Utilities

  • slugifyAuthor(name): string, slugifySeries(value): string
  • authorNamesFromFrontmatter(fm): string[]
  • calculateReadingTime(content): number, calculateWordCount(content): number, normalizeAuthors(...)

Components

  • <MarkdownContent /> — React Server Component that renders a BlogPost.content string. Accepts components, remarkPlugins, rehypePlugins. Fenced ```mermaid blocks render as diagrams when the optional mermaid peer (^11) is installed (see Content & frontmatter).
  • defaultMarkdownComponents — the default element map used by MarkdownContent; merge overrides via the components prop.
  • <OgImage /> — opinionated layout for next/og Open Graph images. Pair with app/[…]/opengraph-image.tsx.

Errors

  • MdxBlogError (base), BlogPostNotFoundError, FileReadError, DirectoryError.

@next-md-blog/core/next

  • getRobots(site): MetadataRoute.Robots — typed for app/robots.ts.
  • Re-exports: generateWebsiteSchema, composeSitemap, composeLlmsTxt, composeLlmsFullTxt.

Public types

  • SiteConfig, SiteOrganization, PostalAddress, ContactPoint, Author
  • CollectionConfig<T>, Collection<T>, ResolvedCollectionConfig<T>, CollectionDefaults, RssOptions
  • ContentDoc<T>, ContentMetadata<T>, BaseFrontmatter, BlogPostFrontmatter
  • FaqItem, HowToFrontmatter, HowToStepFrontmatter (FAQPage / HowTo JSON-LD from frontmatter)
  • Breadcrumb, ReadOptions, MetadataOptions, SchemaOptions, SchemaGraphOptions
  • SchemaBuilder<T>, SchemaBuilderContext<T>
  • ComposeSitemapOptions, ComposeLlmsTxtOptions, WebsiteSchemaOptions
Last updated on