Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lume/core/site.ts>default

🔥 Static site generator for Deno 🦕
Very Popular
Go to Latest
class default
import { default } from "https://deno.land/x/lume@v1.15.3/core/site.ts";

This is the heart of Lume, it contains everything needed to build the site

Constructors

new
default(options?: Partial<SiteOptions>)

Properties

_data: Record<string, unknown>

Internal data. Used to save arbitrary data by plugins and processors

componentLoader: ComponentLoader

To load reusable components

dataLoader: DataLoader

To load all _data files

events: Events<SiteEvent>

To listen and dispatch events

readonly
files: StaticFile[]

The static files to be copied are stored here

formats: Formats

Info about how to handle different file formats

globalComponents: Components

Global components shared by all templates

readonly
globalData: Data
hooks: Record<string, (...args: any[]) => void>

Hooks installed by the plugins

includesLoader: IncludesLoader

To load all _includes files (layouts, templates, etc)

logger: Logger

To output messages to the console

readonly
onDemandPages: Page[]

Pages that should be rendered on demand

options: SiteOptions
pageLoader: PageLoader

To load all pages

pagePreparer: PagePreparer

To prepare the pages before rendering

readonly
pages: Page[]

The generated pages are stored here

preprocessors: Processors

To store and run the pre-processors

processors: Processors

To store and run the processors

reader: Reader

To read the files from the filesystem

renderer: Renderer

To render the pages using any template engine

scopedData: Map<string, Data>

Data assigned with site.data()

scopes: Scopes

To update pages of the same scope after any change

scripts: Scripts

To run scripts

source: Source

To scan the src folder

writer: Writer

To write the generated pages in the dest folder

Methods

addEventListener(
listener: EventListener<SiteEvent> | string,
options?: EventOptions,
): this

Add a listener to an event

build(): Promise<void>

Build the entire site

cacheFile(filename: string, data: Data): this

Save into the cache the content of a file

clear(): Promise<void>

Clear the dest directory and any cache

component(context: string, component: Component): this

Register an extra component accesible by the layouts

copy(from: string, to?: string | ((path: string) => string)): this

Copy static files or directories without processing

copy(from: string[], to?: (path: string) => string): this
data(
name: string,
value: unknown,
scope?,
): this

Register extra data accessible by the layouts

dest(...path: string[]): string

Returns the full path to the dest directory. Use the arguments to return a subpath

dispatchEvent(event: SiteEvent): Promise<boolean>

Dispatch an event

engine(extensions: string[], ...engines: Engine[]): this

Register the engines for some extensions

filter(
name: string,
filter: Helper,
async?,
): this

Register a template filter

getContent(file: string, unnamed 1?: ResolveOptions): Promise<string | Uint8Array | undefined>

Get the content of a file. Resolve the path if it's needed.

helper(
name: string,
fn: Helper,
options: HelperOptions,
): this

Register a template helper

ignore(...paths: (string | ScopeFilter)[]): this

Ignore one or several files or directories

includes(extensions: string[], path: string): this

Register an import path for some extensions

loadAssets(extensions: string[], pageLoader?: Loader): this

Register an assets loader for some extensions

loadComponents(
extensions: string[],
componentLoader?: Loader,
engine: Engine,
): this

Register a component loader for some extensions

loadData(extensions: string[], dataLoader?: Loader): this

Register a data loader for some extensions

loadPages(
extensions: string[],
pageLoader?: Loader,
engine?: Engine,
): this

Register a page loader for some extensions

preprocess(extensions: Extensions, preprocessor: Processor): this

Register a preprocessor for some extensions

preprocessAll(extensions: Extensions, processor: MultiProcessor): this

Register a multipreprocessor for some extensions

process(extensions: Extensions, processor: Processor): this

Register a processor for some extensions

processAll(extensions: Extensions, processor: MultiProcessor): this

Register a multiprocessor for some extensions

remoteFile(filename: string, url: string): this

Define a remote fallback for a missing local file

renderPage(file: string): Promise<Page | undefined>

Render a single page (used for on demand rendering)

root(...path: string[]): string

Returns the full path to the root directory. Use the arguments to return a subpath

run(name: string, options?: ScriptOptions): Promise<boolean>

Runs a script or function registered previously

scopedUpdates(...scopes: ScopeFilter[]): this

Define independent scopes to optimize the update process

script(name: string, ...scripts: ScriptOrFunction[]): this

Register a script or a function, so it can be executed with lume run

src(...path: string[]): string

Returns the full path to the src directory. Use the arguments to return a subpath

update(files: Set<string>): Promise<void>

Reload some files that might be changed

url(path: string, absolute?): string

Return the URL of a path

use(plugin: Plugin): this

Use a plugin