Since 0.1.0
getEntry
Read one entry by slug.
Reads a single file by slug, validates it, and applies the selected view.
const post = await postCollection.getEntry("hello-world");
const detail = await postCollection.getEntry("hello-world", { view: "detail" });
Signature
collection.getEntry(slug: Slug, options?: { view?: ViewName }): Promise<Entry>;
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
slug | string | yes | Filename without the extension. Autocompletes after qino build | |
options.view | view name | no | "default" | A view declared in views |
Returns
Promise<Entry>, shaped like one element of getEntries.
Filter interaction
If the selected view has a filter and it rejects this entry, getEntry throws rather than returning it. Select a view without a filter, such as view({}), to read every entry.
Throws
Entry "<slug>" in collection "<directory>" is excluded by view "<view>".- A raw
ENOENTerror from Node when the file does not exist. Unknown view "<name>". Available views: <names>.- Validation, relation, and augment errors. See Errors.