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 whether a collection exists. A collection exists if it has a
_collection.yaml
file in it.
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 the parent collection object.
Returns the absolute parent directory path of the collection.
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 a list of subcollections within this collection (recursively).
Returns a list of documents in this collection (recursively).
Options for which docs are returned.
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.
A reference to the pod object.
The starting podPath to find.
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.
Normalize path to collection.
content/pages/
becomes /content/pages
Generated using TypeDoc
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.