CMS Integration

Experimental

Content Loader is an experimental feature (@experimental). The API may change in future releases.

Introduction

Valaxy supports fetching content from external CMS platforms via Content Loaders. Loaders run before Vite starts, writing remote content as .md files that integrate automatically into the routing and markdown pipeline.

This means:

  • CMS content shares the same features as local .md files (routing, search, RSS, etc.)
  • No theme or layout modifications needed
  • Incremental caching ensures only changed content is rewritten

How It Works

  1. Content Loaders run before the Vite dev server or build starts
  2. Each loader fetches content from an external CMS, returning ContentItem[]
  3. Items are written as .md files to .valaxy/content/pages/
  4. These files are automatically picked up by vue-router’s file-based routing
  5. Existing markdown processing, search indexing, and RSS generation work unchanged

Defining a Content Loader

Use defineContentLoader() to create a Content Loader:

loaders/my-cms.ts
ts[object Promise]

Configuration

Register Content Loaders in valaxy.config.ts:

valaxy.config.ts
ts[object Promise]

Using with Addons

Some Valaxy addons provide Content Loaders automatically. When using such addons, you don’t need to configure loaders manually — the addon’s setup() function injects the loader for you:

valaxy.config.ts
ts[object Promise]

API Reference

ContentItem

Represents a single piece of content fetched from an external source.

ContentLoaderContext

The context object passed to every loader’s load() function.

ContentLoader

The full loader definition interface.

ts[object Promise]

Dev Mode Polling

Set devPollInterval (in milliseconds) to have a loader periodically re-fetch content during development. This is useful for near-real-time preview while editing CMS content.

ts[object Promise]

TIP

Polling only runs in dev mode. In build mode, content is fetched once.

Incremental Caching

Content Loaders use digest-based incremental caching:

  • Each item’s MD5 digest is recorded in a manifest file
  • On subsequent loads, unchanged items are skipped
  • Stale files (present in previous manifest but not current output) are automatically removed
  • You can provide a custom digest on ContentItem (e.g. a CMS revision ID)

Transform

Use transform to modify each content item before it is written to disk:

ts[object Promise]

Hooks

Content Loaders provide two lifecycle hooks:

HookDescription
content:before-loadFired before all content loaders start fetching
content:loadedFired after all content loaders have finished
valaxy.config.ts
ts[object Promise]

Integration Addons

The following Valaxy addons integrate specific CMS platforms using Content Loaders:

References


To Be Continued.

Contributors