Options
All
  • Public
  • Public/Protected
  • All
Menu

Pods are the "command center" for all operations within a site. Pods hold references to things like the build environment, template engines, file system accessors, routes, etc. Pods provide an interaction model for accessing the different elements of a site and operating on them.

Hierarchy

  • Pod

Index

Constructors

constructor

Properties

Readonly builder

builder: Builder

Readonly cache

cache: Cache

config

config: PodConfig

defaultContentPodPath

defaultContentPodPath: string = '/content/'

defaultView

defaultView: DocumentView = '/views/base.njk'

Readonly engines

Readonly env

Readonly plugins

plugins: Plugins

Readonly profiler

profiler: Profiler

Readonly root

root: string

Readonly router

router: Router

Static BuiltInPlugins

BuiltInPlugins: PluginConstructor[] = ...

Static DefaultConfigFiles

DefaultConfigFiles: string[] = ...

Static DefaultLocalization

DefaultLocalization: LocalizationConfig = ...

Accessors

basePath

  • get basePath(): undefined | string
  • Returns the base URL path where the site is "mounted". This property is meant to be used in conjunction with the $path configuration in content.

    For example, if you want to generate your site to: /mysite/, /mysite/about/, /mysite/static/main.css, etc. You would use in _collection.yaml:

    $path: /${pod.basePath}/${doc.basename}/

    Returns undefined | string

defaultLocale

  • Returns the default locale for the pod. The default locale can be overwritten in amagaki.ts.

    Returns Locale

locales

  • Returns a set of the pod's global locales. Global locales are defined in amagaki.ts.

    Returns Set<Locale>

localization

meta

yamlSchema

  • get yamlSchema(): Schema
  • Returns the YAML schema used to serialize and deserialize all YAML documents that go through the pod.

    Returns Schema

Methods

collection

  • Returns a collection object. If no _collection.yaml file is found within the requested directory, the directory will be walked upwards until finding a directory containing a _collection.yaml file. If no _collection.yaml is found, no collection will be returned.

    Parameters

    • podPath: string

      The podPath to the collection.

    Returns null | Collection

collections

  • Lists collections using glob patterns, as outlined by the glob module.

    Various techniques can be used to list collections depending on your needs:

    // All top-level collections:
    pod.collections('/content/**')
    
    // All top-level collections, sorted by the field "order":
    pod.collections('/content/**', {sort: 'order'})
    
    // Both the "pages" and "posts" collections:
    pod.collections(['/content/posts/*', '/content/pages/*'])
    
    @param patterns A list of glob patterns or a single glob pattern. If
    nothing is supplied, all docs within the pod will be returned.
    

    Parameters

    Returns Collection[]

configure

  • Configures a configuration update on the pod based on the provided config. Should only be called once on a pod.

    Parameters

    Returns void

deleteFileAsync

  • deleteFileAsync(podPath: string): Promise<void>
  • Deletes a file within the pod.

    Parameters

    • podPath: string

    Returns Promise<void>

doc

  • Returns a document object.

    Parameters

    • podPath: string

      The podPath to the document.

    • Optional locale: Locale

      The document's locale. If not provided, the pod's default locale will be used to return the document.

    Returns Document

docs

  • Lists documents using glob patterns, as outlined by the glob module.

    Note the following behavior:

    • Files prefixed with _ are ignored.
    • Only files with supported doc extensions are returned.

    Various techniques can be used to list docs depending on your needs:

    // All docs within the "pages" collection:
    pod.docs('/content/pages/**')
    
    // Only Markdown docs within the "pages" collection:
    pod.docs('/content/pages/**\/*.md')
    
    // All docs within both the "pages" and "posts" collections:
    pod.docs(['/content/pages/**', '/content/posts/**'])
    
    // All Markdown docs within the entire pod:
    pod.docs('**\/*.md')
    
    // All docs named `index.yaml` within the entire pod:
    pod.docs('**\/index.yaml')
    

    Parameters

    • Optional patterns: string | string[]

      A list of glob patterns or a single glob pattern. If nothing is supplied, all docs within the pod will be returned.

    • Optional options: DocumentListOptions

    Returns Document[]

dumpYaml

  • dumpYaml(data: any): string
  • Dumps an object to a YAML string, using the pod's schema.

    Parameters

    • data: any

    Returns string

fileExists

  • fileExists(podPath: string): Boolean
  • Returns whether a file exists within the pod.

    Parameters

    • podPath: string

      The podPath to the file.

    Returns Boolean

getAbsoluteFilePath

  • getAbsoluteFilePath(podPath: string): string
  • Returns the absolute file path on the file system.

    Parameters

    • podPath: string

      The podPath to the file or directory.

    Returns string

locale

  • Returns a locale object.

    Parameters

    • id: string

      The locale identifier code.

    Returns Locale

readFile

  • readFile(path: string): string
  • Reads a file into a string.

    Parameters

    • path: string

    Returns string

readYaml

  • readYaml(podPath: string): any
  • Reads YAML content from a file into an object.

    Parameters

    • podPath: string

    Returns any

readYamlString

  • readYamlString(content: string, cacheKey?: string): any
  • Reads YAML content into an object.

    Parameters

    • content: string

      The YAML content as string to read.

    • Optional cacheKey: string

      A key used for caching the read.

    Returns any

setEnvironment

  • setEnvironment(name: string): void
  • Sets the environment using settings specified from one of the preconfigured environments in amagaki.ts. This is useful for changing behavior depending on your build environment, such as outputting different content between dev, staging, and prod.

    Parameters

    • name: string

    Returns void

staticFile

  • Returns a static file object.

    Parameters

    • podPath: string

      The podPath to the static file.

    Returns StaticFile

string

toString

  • toString(): string

walk

  • walk(podPath: string): string[]
  • Walks a podPath directory an returns a flattened list of podPaths within that directory, recursively in a flat list. For example, if walking /content/pages/, it might return: /content/pages/index.yaml, /content/pages/subpages/index.yaml, etc.

    Parameters

    • podPath: string

    Returns string[]

warmup

  • warmup(): Promise<void>

writeFileAsync

  • writeFileAsync(podPath: string, content: string): Promise<void>
  • Writes a file to a location within the pod.

    Parameters

    • podPath: string
    • content: string

    Returns Promise<void>

Generated using TypeDoc