Skip to content

Content query

I think to expose querying interface similar to facets. It is to some extent is limited. But if people need more they can use generated DB directly.

Related:

Curently available

export type DocumentsOtions = {
slug?: string;
url?: string;
frontmatter?: JsonLimitedObject;
sort?: ["updated_at", SortDirection];
};
documents(options?: DocumentsOtions) {}

Open questions

Alternative approach

Use some kind of DSL, like https://orm.drizzle.team/docs/operators

Built-in fields vs frontmatter

There are built-in fields: path, url, updated_at (will be added type). They don’t require schema.

What to do if we have same fields in frontmatter? We can explicitly target those fields with prefix frontmatter or fm.

  • sort: ["updated_at", "asc"] will sort by built-in field
  • sort: ["fm.updated_at", "asc"] will sort by field in frontmatter
  • sort: ["something", "asc"] will sort by field in frontmatter (because there is no such built-in field)
  • sort: ["something.else", "asc"] will sort by field else nested in object something in frontmatter
    • which means we can’t use fields with . in it. In order to support . probably need to intrdouce escape sequence \.