On this page:
8.7.1 Collecting and Building
collect
collect/  call-with-page
build!
site-info
current-site-info
page
8.7.2 Development Server
start-server
8.7.3 Logging
camp-logger
log-camp-fatal
log-camp-error
log-camp-warning
log-camp-info
log-camp-debug
9.1

8.7 Low-Level API🔗ℹ

    8.7.1 Collecting and Building

    8.7.2 Development Server

    8.7.3 Logging

8.7.1 Collecting and Building🔗ℹ

 (require camp/build) package: camp-lib

The camp/build module provides the two-pass build system for Camp sites.

procedure

(collect site)  site-info?

  site : site?
Performs the collect pass over a site. Traverses all documents in each collection, building indexes for cross-reference resolution: a page index mapping slugs to URLs, a term index mapping term names to URL fragments, and taxonomy indexes for each collection.

procedure

(collect/call-with-page site slug proc)  any

  site : site?
  slug : string?
  proc : (-> document? context? any)
Collects the site, looks up the page matching slug, and calls proc with the page’s document and render context. The current-site-info parameter is set for the duration of proc, so cross-reference functions like get-collection and get-taxonomy-pages work normally.

This is useful for rendering or processing a single page with full site context without performing a complete build!. The slug is matched case-insensitively. Raises an error if no page with the given slug exists.

(collect/call-with-page my-site "my-post" my-render-function)

procedure

(build! site info)  void?

  site : site?
  info : site-info?
Performs the build pass. For each page, calls its collection’s render function with the document and context. Render functions call camp-doc->html-xexpr to render the body (which resolves cross-references). Writes the returned x-expression to the output folder as HTML.

struct

(struct site-info (pages term-index page-index taxonomy-index)
    #:extra-constructor-name make-site-info
    #:transparent)
  pages : (listof page?)
  term-index : hash?
  page-index : hash?
  taxonomy-index : hash?
Collected information about a site, built during the collect pass. Contains all processed pages, an index mapping term names to URLs, an index mapping slugs to page-links, and a nested index for taxonomy lookups.

parameter

(current-site-info)  (or/c site-info? #f)

(current-site-info info)  void?
  info : (or/c site-info? #f)
A parameter containing the current site-info during the build phase. Set by build! before rendering pages. Used internally by get-collection, get-taxonomy-terms, and get-taxonomy-pages. Returns #f outside of a build context.

struct

(struct page (source-path output-path doc slug collection-name)
    #:extra-constructor-name make-page
    #:transparent)
  source-path : path?
  output-path : path?
  doc : any/c
  slug : string?
  collection-name : string?
Represents a page during the build process. Contains the source file path, computed output path, the Punct document, URL slug, and the name of the collection it belongs to.

8.7.2 Development Server🔗ℹ

 (require camp/serve) package: camp-lib

The camp/serve module provides a development server for local testing.

procedure

(start-server output-folder    
  [#:port port    
  #:log-format log-format])  (-> void?)
  output-folder : path-string?
  port : exact-nonnegative-integer? = 8000
  log-format : (or/c 'modern 'apache) = 'modern
Starts a static file server serving files from output-folder. Returns a shutdown procedure that stops the server when called. By default, listens on port 8000.

The log-format parameter controls request logging: 'modern produces a clean HH:MM:SS METHOD PATH STATUS format suitable for colorized terminal output, while 'apache produces traditional Apache combined log format.

Note: This function only starts a static server. File watching and automatic rebuilds are provided by the raco camp serve command, which uses this function internally.

8.7.3 Logging🔗ℹ

 (require camp/log) package: camp-lib

The camp/log module provides structured logging for Camp operations.

The Camp logger instance, using the topic 'camp. Subscribe to this logger to receive Camp-related log messages.

syntax

(log-camp-fatal string-expr arg ...)

syntax

(log-camp-error string-expr arg ...)

syntax

(log-camp-warning string-expr arg ...)

syntax

(log-camp-info string-expr arg ...)

syntax

(log-camp-debug string-expr arg ...)

Log messages of varying severity levels to the Camp logger.