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

Properties

builder: Builder
cache: Cache
config: PodConfig
defaultContentPodPath: string = '/content/'
defaultView: DocumentView = '/views/base.njk'
plugins: Plugins
profiler: Profiler
root: string
router: Router
BuiltInPlugins: PluginConstructor[] = ...
DefaultConfigFiles: string[] = ...
DefaultLocalization: LocalizationConfig = ...

Accessors

  • get basePath(): 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 string

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

    Returns Schema

Methods

  • 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 Collection

  • 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[]

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

    Parameters

    Returns void

  • deleteFileAsync(podPath: string): Promise<void>
  • 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

  • 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(data: any): string
  • fileExists(podPath: string): Boolean
  • Returns whether a file exists within the pod.

    Parameters

    • podPath: string

      The podPath to the file.

    Returns Boolean

  • 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

  • readFile(path: string): string
  • readYaml(podPath: string): any
  • 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(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

  • toString(): string
  • 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(): Promise<void>
  • writeFileAsync(podPath: string, content: string): Promise<void>

Generated using TypeDoc