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— fullOrganizationJSON-LD (founder, foundingDate, address, contactPoint, wikidata insameAs).generateWebsiteSchema(site, opts?)—WebSite+ optionalSearchAction.
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 byfrontmatter.datedesc)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?): stringindexUrl(locale?): stringhreflangMap(slug, locales): Promise<Record<string, string>>— only locales with a translation.
SEO
metadata(doc, opts?): Promise<Metadata>— NextMetadata.opts.titleTemplateaccepts'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: trueadds default selectors;opts.extendmutates the doc node.breadcrumbsSchema(doc, breadcrumbs?, opts?)—BreadcrumbListJSON-LD.
Output
rssXml(opts?): Promise<string>— RSS 2.0 XML string.rssResponse(opts?): Promise<NextResponse>— fully-wired Next response withCache-Control.sitemapEntries(opts: { locales }): Promise<MetadataRoute.Sitemap>— one row per slug, withxhtml:hreflangalternates 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-widellms.txt.composeLlmsFullTxt({ site, collections, locales, summary? }): Promise<string>.
Utilities
slugifyAuthor(name): string,slugifySeries(value): stringauthorNamesFromFrontmatter(fm): string[]calculateReadingTime(content): number,calculateWordCount(content): number,normalizeAuthors(...)
Components
<MarkdownContent />— React Server Component that renders aBlogPost.contentstring. Acceptscomponents,remarkPlugins,rehypePlugins. Fenced```mermaidblocks render as diagrams when the optionalmermaidpeer (^11) is installed (see Content & frontmatter).defaultMarkdownComponents— the default element map used byMarkdownContent; merge overrides via thecomponentsprop.<OgImage />— opinionated layout fornext/ogOpen Graph images. Pair withapp/[…]/opengraph-image.tsx.
Errors
MdxBlogError(base),BlogPostNotFoundError,FileReadError,DirectoryError.
@next-md-blog/core/next
getRobots(site): MetadataRoute.Robots— typed forapp/robots.ts.- Re-exports:
generateWebsiteSchema,composeSitemap,composeLlmsTxt,composeLlmsFullTxt.
Public types
SiteConfig,SiteOrganization,PostalAddress,ContactPoint,AuthorCollectionConfig<T>,Collection<T>,ResolvedCollectionConfig<T>,CollectionDefaults,RssOptionsContentDoc<T>,ContentMetadata<T>,BaseFrontmatter,BlogPostFrontmatterFaqItem,HowToFrontmatter,HowToStepFrontmatter(FAQPage / HowTo JSON-LD from frontmatter)Breadcrumb,ReadOptions,MetadataOptions,SchemaOptions,SchemaGraphOptionsSchemaBuilder<T>,SchemaBuilderContext<T>ComposeSitemapOptions,ComposeLlmsTxtOptions,WebsiteSchemaOptions
Last updated on