• Public
  • Public/Protected
  • All

Collections represent groups of documents. Collections allow documents to share things, such as locales, URL path formats, views, etc. A collection exists as long as a _collection.yaml file exists within the pod's content directory. If a directory exists without a _collection.yaml, it will look up until a _collection.yaml is found. Arbitrary data can also be specified on the collection's _collection.yaml fields, and then accessed from documents within that collection.


  • Collection




_fields: any
collectionPath: string
pod: Pod
podPath: string
ConfigFile: string = '_collection.yaml'


  • get basename(): string
  • Returns the collection's basename.

    A collection's basename is its folder's name, without the full path.

    The basename for /content/pages is pages. The basename for /content/pages/foo is foo.

    Returns string

  • get exists(): Boolean
  • get fields(): any
  • Returns the index document from the collection. The index document is the document whose basename is index. If two documents with different extensions are located, the first one found is returned.

    Returns Document

  • get parentPath(): string
  • Returns a list of the parent collections, up to the top-most collection.

    This may be useful for situations where you need to walk through content relationships. Examples include generating site navigation menus, breadcrumbs, or various listings of collections and their documents.

    Note that a collection only exists if its folder contains a _collection.yaml. In other words, a collection /content/foo/bar will only return /content/foo in its list of parents if /content/foo/_blueprint.yaml exists.

    Returns Collection[]


  • toString(): string
  • Finds a collection object by testing whether the given directory has a _collection.yaml file within it, and if not, it will walk upwards until one is found. If the root of the pod is reached, no collection requested was located, and null will be returned.


    • pod: Pod

      A reference to the pod object.

    • path: string

      The starting podPath to find.

    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:
    Collection.list(pod, '/content/**')

    // All top-level collections, sorted by the field "order":
    Collection.list(pod, '/content/**', {sort: 'order'})

    // Both the "pages" and "posts" collections:
    Collection.list(pod, ['/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.


    Returns Collection[]

  • normalizePath(path: string): string

Generated using TypeDoc