Skip to content

ToSSGOptions

reference
1 min readUpdated

Kind: Interface

Source: src/helper/ssg/ssg.ts

Part of: Helper

ToSSGOptions configures static site generation in the SSG helper. It defines the output directory, request and generation hooks, concurrency, extension mappings, and plugins used during generation.

Properties

PropertyType
dirstring
beforeRequestHook`BeforeRequestHook
afterResponseHook`AfterResponseHook
afterGenerateHook`AfterGenerateHook
concurrencynumber
extensionMapRecord<string, string>
pluginsSSGPlugin[]

Diagram

mermaid
graph LR
  Options[ToSSGOptions]
  Options --> Dir[dir]
  Options --> Before[beforeRequestHook]
  Options --> AfterResponse[afterResponseHook]
  Options --> AfterGenerate[afterGenerateHook]
  Options --> Concurrency[concurrency]
  Options --> Extensions[extensionMap]
  Options --> Plugins[plugins]

Usage

ts
import type { ToSSGOptions } from './ssg'

const options: ToSSGOptions = {
  dir: './dist',
  beforeRequestHook: async () => {
    // Run before an SSG request.
  },
  afterResponseHook: async () => {
    // Run after an SSG response.
  },
  afterGenerateHook: async () => {
    // Run after generated output is written.
  },
  concurrency: 4,
  extensionMap: {
    '.html': '.html',
    '.json': '.json',
  },
  plugins: [],
}

AI Coding Instructions

  • Set dir to the directory where generated files should be written.
  • Accept either a single hook or an array of hooks for each hook field.
  • Keep beforeRequestHook, afterResponseHook, and afterGenerateHook aligned with their execution stage.
  • Set extensionMap entries to map generated source extensions to output extensions.
  • Pass SSG integrations through plugins as SSGPlugin instances.

Was this page helpful?

Download as PDF
ToSSGOptions — Hono (narrator proof)