Skip to content
qino

Since 0.1.0

getEntry

Read one entry by slug.

Reads a single file by slug, validates it, and applies the selected view.

src/app/posts/[slug]/page.tsx
const post = await postCollection.getEntry("hello-world");
const detail = await postCollection.getEntry("hello-world", { view: "detail" });

Signature

@qino/cms
collection.getEntry(slug: Slug, options?: { view?: ViewName }): Promise<Entry>;

Parameters

NameTypeRequiredDefaultDescription
slugstringyesFilename without the extension. Autocompletes after qino build
options.viewview nameno"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 ENOENT error from Node when the file does not exist.
  • Unknown view "<name>". Available views: <names>.
  • Validation, relation, and augment errors. See Errors.

See also