Extensions

CarvePress has two extension layers: Carve engine extensions that render markup, and site extensions that subscribe to build events.

Presets

PresetIncluded Carve engine factories
minimalheading permalinks plus CarvePress code, compare, playground, images, and table scrolling
docstabs, details, mathBlock, externalLinks, tableOfContents, tocPlacement, wikilinks
fullall docs factories plus headingNumbers, glossary, index, citations, codeCallouts, colorSwatch, spoiler, listTable, imgFence, defaultAttributes

CarvePress always wraps the preset with Shiki, table scrolling, compare, playground, code groups, heading permalinks, and image defaults.

Site Extension Events

EventPayloadUse
buildStarted{ config }Validate settings or capture normalized config.
contentDiscovered{ pages }Add virtual pages or filter pages.
rendererCreated{ extensions }Add Carve render extensions.
pageRendered{ rendered, html }Post-process rendered HTML.
pageWritten{ rendered, outPath }Track emitted files.
buildCompleted{ rendered, outDir }Write derived artifacts.

Worked Example

site extension
import type { SiteExtension } from '@markup-carve/carve-press'
import { writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'

export function routeManifest(): SiteExtension {
  return {
    name: 'route-manifest',
    setup(bus) {
      bus.on('buildCompleted', async ({ rendered, outDir }) => {
        const routes = rendered.map((page) => page.searchDoc.route)
        await writeFile(resolve(outDir, 'routes.json'), JSON.stringify(routes, null, 2))
      }, 'route-manifest')
    },
  }
}

Built-in site extensions include searchIndex, sitemap, llmsTxt, blog, feed, and redirects.

Edit this page

Last updated