Module

x/lume/core/site.ts>default

🔥 Static site generator for Deno 🦕
Very Popular
Latest
class default
import { default } from "https://dotland.deno.dev/x/lume@v2.3.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<any>

To listen and dispatch events

fetch: Deno.ServeHandler
readonly
files: StaticFile[]

The static files to be copied are stored here

formats: Formats

Info about how to handle different file formats

fs: FS

To read the files from the filesystem

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

Hooks installed by the plugins

readonly
onDemandPages: Page[]

Pages that should be rendered on demand

options: SiteOptions
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

renderer: Renderer

To render the pages using any template engine

scopedComponents: Map<string, Components>

Components created with site.component()

scopedData: Map<string, RawData>

Data assigned with site.data()

scopedPages: Map<string, RawData[]>

Pages created with site.page()

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<K extends SiteEventType>(
type: K,
listener: EventListener<Event & SiteEvent<K>> | string,
options?: EventOptions,
): this

Add a listener to an event

build(): Promise<void>

Build the entire site

clear(): Promise<void>

Clear the dest directory and any cache

component(
context: string,
component: Component,
scope?,
): 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
copyRemainingFiles(filter?: (path: string) => string | boolean): this

Copy the remaining files

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

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

Register a template filter

getContent(file: string, loader: Loader): Promise<string | Uint8Array | undefined>

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

getOrCreatePage(url: string, loader?: Loader): Promise<Page>

Returns a File system watcher of the site

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

Register a template helper

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

Ignore one or several files or directories

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

Register an assets loader for some extensions

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

Register a data loader for some extensions

loadPages(extensions: string[], options?: LoadPagesOptions | Loader): this

Register a page loader for some extensions

mergeKey(
key: string,
scope?,
): this

Register a merging strategy for a data key

page(data: Partial<Data>, scope?): this

Register a page

Register a basename parser

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

Register a preprocessor for some extensions

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

Register a processor for some extensions

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

Define a remote fallback for a missing local file

renderPage(file: string, extraData?: Record<string, unknown>): 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): 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

Returns a server

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