github fuma-nama/fumadocs @fumadocs/asyncapi@0.3.0

latest releases: fumadocs-openapi@11.3.0, fumadocs-obsidian@1.0.2, fumadocs-mdx@15.3.1...
4 hours ago

Redesign source API

Content sources can hook into the static loader they are attached to, and dynamic sources can opt out of the loader's in-memory file cache.

configureStatic runs when a source is attached to loader(), and again whenever dynamicLoader() builds a new static loader:

export function createMySource(): DynamicSource {
  return {
    cache: 'custom',
    async files() {
      return loadFiles();
    },
    configureStatic({ loader, source }) {
      // `loader` is the created static loader
      // `source` is the record key when using named sources
    },
    configure(loader, { source }) {
      loader.invalidate();
    },
  };
}
  • cache: 'memory' (default): files() is called once until invalidate().
  • cache: 'custom': the source caches itself. dynamicLoader() re-runs files() on get() and rebuilds only when the file list is shallowly different (by identity).

Integrations

GraphQL cross-links are generated from the attached loader instead of a baseUrl option on staticSource(). Local, OpenAPI, and AsyncAPI dynamicSource() use cache: 'custom' and reuse generated files by identity until invalidate().

Sanity now uses cache: 'custom' when given a sanityFetch from next-sanity/live, calling invalidate() in draft mode is no longer needed.

Cache the document proxy in toStaticData

Matches fumadocs-openapi: the magic proxy is created once per document instead of once per generated page.

Don't miss a new fumadocs release

NewReleases is sending notifications on new releases.