Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

kirby-types

johannschopplich1.7kMIT1.0.0TypeScript support: included

A collection of TypeScript types for the Kirby CMS

getkirby, kirby-cms, kirby, kql, query-language, query, typescript

readme

kirby-types

NPM version

A collection of TypeScript types to work with Kirby CMS, mainly in the context of the Kirby Query Language and headless Kirby usage.

Setup

# pnpm
pnpm add -D kirby-types

# npm
npm i -D kirby-types

# yarn
yarn add -D kirby-types

Basic Usage

import type { KirbyQuery, ParseKirbyQuery } from "kirby-types";

// Strictly typed query
const query: KirbyQuery = 'page.children.filterBy("featured", true)';

// Parse query strings into structured objects
type BasicQuery = ParseKirbyQuery<"site">;
// Result: { model: "site"; chain: [] }

type DotNotationQuery = ParseKirbyQuery<"page.children.listed">;
// Result: {
//   model: "page";
//   chain: [
//     { type: "property"; name: "children" },
//     { type: "property"; name: "listed" }
//   ]
// }

type MethodQuery = ParseKirbyQuery<'site("home")'>;
// Result: {
//   model: "site";
//   chain: [{ type: "method"; name: "site"; params: '"home"' }]
// }

type ComplexQuery =
  ParseKirbyQuery<'page.children.filterBy("status", "published")'>;
// Result: {
//   model: "page";
//   chain: [
//     { type: "property"; name: "children" },
//     { type: "method"; name: "filterBy"; params: '"status", "published"' }
//   ]
// }

API

By clicking on a type name, you will be redirected to the corresponding TypeScript definition file.

API

Query

Blocks

Layout

KQL

License

MIT License © 2022-PRESENT Johann Schopplich