Accent Template API

Queries

cms.assets.get / find / all — the query surface over the whole site, and the row shape it returns.


cms.assets is the query surface over the whole site — routed pages and path-less records alike, because everything is an asset. Every result is a row of the same shape as cms.asset.

get

<% var about = cms.assets.get('about') %>          <!-- one asset by IA address -->
<% var home  = cms.assets.get('') %>               <!-- '' is the homepage -->
<% var first = cms.assets.get({ type: 'post', sort: '-publishedAt' }) %>  <!-- first match -->

get(path) resolves an address the way the wire does: a page wins the path; a miss reads the record at that IA location. It returns null when nothing is there — or, on a public render, when what is there is unpublished or hidden — so guard it: (cms.assets.get('') ?? {}).url.

find

<% var posts = cms.assets.find({
     type: 'post',                 // one type id, or a list of them
     under: cms.asset.path,        // anywhere in this branch
     sort: '-publishedAt',         // a row key or dot path; '-' descends
     limit: 6,
   }) %>
Criterion Meaning
type a content type id, or an array of them
parent direct children of this path ('' = the site root)
under anywhere under this path, the page itself excluded
where a predicate over the row, run after the cheap filters
sort row key or dot path (title, meta.date, -publishedAt); default path
limit, start paging

all() is find({}). Records match parent and under through their IA address ({parent}/{name}); an unnamed record has no address and answers only type and where.

Rows

A row carries id, path, slug, url, is_current, title, type, published, publishedAt, updatedAt, content, meta, options, data, taxonomy, outputs, output(). Two are honest maybes:

  • url is null when no document output serves the asset — a record's bare address is reserved for documents. Its addressable representations hang off output(name).url; row.url || row.output('card')?.url composes.
  • path is null for an unnamed record. Missing paths sort last.

is_current is true on the row that is the asset being rendered — the usual way to highlight the current item in a nav built from a query.

Gates and locale

Public renders never see unpublished pages, records without a published snapshot, or hidden-from-listings pages; preview and editor renders do. The query has no locale filter yet: on a localized site it returns every locale's rows, so filter with where on the row's path prefix until the locale-aware form lands.

Deep records

  • Page queries and metadata
  • Content lanes §9.1 W6 — the missing locale filter
  • R11 — the bare IA address belongs to the document output — why a record's url is null.