coralite

The coralite function is the core processing engine of Coralite. It takes a configuration object and returns an array of objects, each representing one page rendered with its respective HTML content along with other metadata such as document title or render time in milliseconds (ms).

Signature

TypeScript
Code copied!

async function coralite(options: {
  templates: string
  pages: string
  ignoreByAttribute?: Array<Array<string, string>>
}): Promise<
  Array<{
    document: CoraliteDocument
    html: string
    duration: number
  }>
>
    

Parameters

Name Type Attribute Description
options Object Configuration options for the `coralite` function.
options.templates string The file system path to the directory containing Coralite templates. These templates are used to create components during the rendering process.
options.pages string The file system path to the directory containing pages that will be rendered using the provided templates.
options.ignoreByAttribute [string, string][] optional An optional 2D array of element names and their respective attributes to ignore during parsing. For example, `[['div', 'data-ignore']]` ignores `
` elements with a `data-ignore` attribute.

Returns

Signature

TypeScript
Code copied!

async function coralite(options: {
  templates: string
  pages: string
  ignoreByAttribute?: Array<Array<string, string>>
}): Promise<
  Array<{
    document: CoraliteDocument
    html: string
    duration: number
  }>
>
Name Type Attribute Description
document Object
document.item Object An object containing information about the rendered page item.
document.item.name string Document file name.
document.item string Parent file path.
document.item string Parent file path.

Example

JavaScript
Code copied!

coralite({
  templates: './path/to/templates',
  pages: './path/to/pages',
  ignoreByAttribute: [['div', 'data-ignore']],
})
  .then((documents) => {
    console.log(documents)
  })