vite config : ignore /local and /public/** to improve perf

This commit is contained in:
isUnknown 2025-10-02 09:53:59 +02:00
parent 3c9eed7804
commit c11a85e7f8
32 changed files with 1235 additions and 858 deletions

View file

@ -16,21 +16,21 @@ Given a POST request to: `/api/query`
```json
{
"query": "page('photography').children",
"select": {
"url": true,
"title": true,
"text": "page.text.markdown",
"images": {
"query": "page.moodboard",
"select": {
"url": true
}
}
},
"pagination": {
"limit": 10
"query": "page('photography').children",
"select": {
"url": true,
"title": true,
"text": "page.text.markdown",
"images": {
"query": "page.images",
"select": {
"url": true
}
}
},
"pagination": {
"limit": 10
}
}
```
@ -39,48 +39,48 @@ Given a POST request to: `/api/query`
```json
{
"code": 200,
"result": {
"data": [
{
"url": "https://example.com/photography/trees",
"title": "Trees",
"text": "Lorem <strong>ipsum</strong> …",
"images": [
{
"url": "https://example.com/media/pages/photography/trees/1353177920-1579007734/cheesy-autumn.jpg"
},
{
"url": "https://example.com/media/pages/photography/trees/1940579124-1579007734/last-tree-standing.jpg"
},
{
"url": "https://example.com/media/pages/photography/trees/3506294441-1579007734/monster-trees-in-the-fog.jpg"
}
]
},
{
"url": "https://example.com/photography/sky",
"title": "Sky",
"text": "<h1>Dolor sit amet</h1> …",
"images": [
{
"url": "https://example.com/media/pages/photography/sky/183363500-1579007734/blood-moon.jpg"
},
{
"url": "https://example.com/media/pages/photography/sky/3904851178-1579007734/coconut-milkyway.jpg"
}
]
}
],
"pagination": {
"page": 1,
"pages": 1,
"offset": 0,
"limit": 10,
"total": 2
}
},
"status": "ok"
"code": 200,
"result": {
"data": [
{
"url": "https://example.com/photography/trees",
"title": "Trees",
"text": "Lorem <strong>ipsum</strong> …",
"images": [
{
"url": "https://example.com/media/pages/photography/trees/1353177920-1579007734/cheesy-autumn.jpg"
},
{
"url": "https://example.com/media/pages/photography/trees/1940579124-1579007734/last-tree-standing.jpg"
},
{
"url": "https://example.com/media/pages/photography/trees/3506294441-1579007734/monster-trees-in-the-fog.jpg"
}
]
},
{
"url": "https://example.com/photography/sky",
"title": "Sky",
"text": "<h1>Dolor sit amet</h1> …",
"images": [
{
"url": "https://example.com/media/pages/photography/sky/183363500-1579007734/blood-moon.jpg"
},
{
"url": "https://example.com/media/pages/photography/sky/3904851178-1579007734/coconut-milkyway.jpg"
}
]
}
],
"pagination": {
"page": 1,
"pages": 1,
"offset": 0,
"limit": 10,
"total": 2
}
},
"status": "ok"
}
```
@ -116,35 +116,34 @@ return [
### Sending POST Requests
You can use any HTTP request library in your language of choice to make regular POST requests to your `/api/query` endpoint. In this example, we are using [the `fetch` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and JavaScript to retrieve data from our Kirby installation.
You can use any HTTP request library in your language of choice to make regular POST requests to your `/api/query` endpoint. In this example, we are using [ohmyfetch](https://github.com/unjs/ohmyfetch) (a better fetch API for Node and the browser) and JavaScript to retreive data from our Kirby installation.
```js
import { $fetch } from "ohmyfetch";
const api = "https://yoursite.com/api/query";
const username = "apiuser";
const password = "strong-secret-api-password";
const headers = {
Authorization:
"Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
"Content-Type": "application/json",
Accept: "application/json",
Authorization: Buffer.from(`${username}:${password}`).toString("base64"),
};
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('notes').children",
select: {
title: true,
text: "page.text.kirbytext",
slug: true,
date: "page.date.toDate('d.m.Y')",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "page('notes').children",
select: {
title: true,
text: "page.text.kirbytext",
slug: true,
date: "page.date.toDate('d.m.Y')",
},
},
headers,
});
console.log(await response.json());
console.log(response);
```
### `query`
@ -158,15 +157,15 @@ When you don't pass the select option, Kirby will try to come up with the most u
##### Fetching the Site Title
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.title",
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.title",
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -185,15 +184,15 @@ console.log(await response.json());
##### Fetching a List of Page IDs
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.children",
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.children",
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -220,15 +219,15 @@ console.log(await response.json());
Queries can even execute field methods.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.title.upper",
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.title.upper",
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -253,16 +252,16 @@ KQL becomes really powerful by its flexible way to control the result set with t
To include a property or field in your results, list them as an array. Check out our [reference for available properties](https://getkirby.com/docs/reference) for pages, users, files, etc.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.children",
select: ["title", "url"],
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.children",
select: ["title", "url"],
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -311,19 +310,19 @@ console.log(await response.json());
You can also use the object notation and pass true for each key/property you want to include.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.children",
select: {
title: true,
url: true,
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.children",
select: {
title: true,
url: true,
},
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -368,18 +367,18 @@ console.log(await response.json());
Instead of passing true, you can also pass a string query to specify what you want to return for each key in your select object.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.children",
select: {
title: "page.title",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.children",
select: {
title: "page.title",
},
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -409,18 +408,18 @@ console.log(await response.json());
#### Executing Field Methods
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site.children",
select: {
title: "page.title.upper",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "site.children",
select: {
title: "page.title.upper",
},
},
headers,
});
console.log(await response.json());
console.log(response);
```
<details>
@ -452,23 +451,21 @@ console.log(await response.json());
String queries are a perfect way to create aliases or return variations of the same field or property multiple times.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('notes').children",
select: {
title: "page.title",
upperCaseTitle: "page.title.upper",
lowerCaseTitle: "page.title.lower",
guid: "page.id",
date: "page.date.toDate('d.m.Y')",
timestamp: "page.date.toTimestamp",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "page('notes').children",
select: {
title: "page.title",
upperCaseTitle: "page.title.upper",
lowerCaseTitle: "page.title.lower",
guid: "page.id",
date: "page.date.toDate('d.m.Y')",
timestamp: "page.date.toTimestamp",
},
},
headers,
});
console.log(await response.json());
```
<details>
@ -504,19 +501,17 @@ console.log(await response.json());
With such string queries you can of course also include nested data
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('photography').children",
select: {
title: "page.title",
images: "page.moodboard",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "page('photography').children",
select: {
title: "page.title",
images: "page.images",
},
},
headers,
});
console.log(await response.json());
```
<details>
@ -554,24 +549,22 @@ console.log(await response.json());
You can also pass an object with a `query` and a `select` option
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('photography').children",
const response = await $fetch(api, {
method: "post",
body: {
query: "page('photography').children",
select: {
title: "page.title",
images: {
query: "page.images",
select: {
title: "page.title",
images: {
query: "page.moodboard",
select: {
filename: true,
},
},
filename: true,
},
}),
headers,
},
},
},
headers,
});
console.log(await response.json());
```
<details>
@ -623,21 +616,19 @@ Whenever you query a collection (pages, files, users, roles, languages) you can
You can specify a custom limit with the limit option. The default limit for collections is 100 entries.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('notes').children",
pagination: {
limit: 5,
},
select: {
title: "page.title",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "page('notes').children",
pagination: {
limit: 5,
},
select: {
title: "page.title",
},
},
headers,
});
console.log(await response.json());
```
<details>
@ -683,22 +674,20 @@ console.log(await response.json());
You can jump to any page in the resultset with the `page` option.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('notes').children",
pagination: {
page: 2,
limit: 5,
},
select: {
title: "page.title",
},
}),
headers,
const response = await $fetch(api, {
method: "post",
body: {
query: "page('notes').children",
pagination: {
page: 2,
limit: 5,
},
select: {
title: "page.title",
},
},
headers,
});
console.log(await response.json());
```
<details>
@ -735,28 +724,26 @@ console.log(await response.json());
Pagination settings also work for subqueries.
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "page('photography').children",
select: {
title: "page.title",
images: {
query: "page.moodboard",
pagination: {
page: 2,
limit: 5,
},
select: {
filename: true,
},
},
const response = await $fetch(api, {
method: "post",
body: {
query: "page('photography').children",
select: {
title: "page.title",
images: {
query: "page.images",
pagination: {
page: 2,
limit: 5,
},
}),
headers,
select: {
filename: true,
},
},
},
},
headers,
});
console.log(await response.json());
```
### Multiple Queries in a Single Call
@ -764,45 +751,43 @@ console.log(await response.json());
With the power of selects and subqueries you can basically query the entire site in a single request
```js
const response = await fetch(api, {
method: "post",
body: JSON.stringify({
query: "site",
const response = await $fetch(api, {
method: "post",
body: {
query: "site",
select: {
title: "site.title",
url: "site.url",
notes: {
query: "page('notes').children.listed",
select: {
title: "site.title",
url: "site.url",
notes: {
query: "page('notes').children.listed",
select: {
title: true,
url: true,
date: "page.date.toDate('d.m.Y')",
text: "page.text.kirbytext",
},
},
photography: {
query: "page('photography').children.listed",
select: {
title: true,
images: {
query: "page.moodboard",
select: {
url: true,
alt: true,
caption: "file.caption.kirbytext",
},
},
},
},
about: {
text: "page.text.kirbytext",
},
title: true,
url: true,
date: "page.date.toDate('d.m.Y')",
text: "page.text.kirbytext",
},
}),
headers,
},
photography: {
query: "page('photography').children.listed",
select: {
title: true,
images: {
query: "page.images",
select: {
url: true,
alt: true,
caption: "file.caption.kirbytext",
},
},
},
},
about: {
text: "page.text.kirbytext",
},
},
},
headers,
});
console.log(await response.json());
```
### Allowing Methods
@ -951,7 +936,7 @@ If you want to fully allow access to an entire class without putting an intercep
return [
'kql' => [
'classes' => [
'allowed' => [
'allow' => [
'Kirby\Cms\System'
]
]
@ -967,23 +952,8 @@ KQL only offers access to data in your site. It does not support any mutations.
## Plugins
- [KQL + 11ty](https://github.com/getkirby/eleventykit)
- [KQL + Nuxt](https://nuxt-kql.jhnn.dev)
## What's Kirby?
- **[getkirby.com](https://getkirby.com)** Get to know the CMS.
- **[Try it](https://getkirby.com/try)** Take a test ride with our online demo. Or download one of our kits to get started.
- **[Documentation](https://getkirby.com/docs/guide)** Read the official guide, reference and cookbook recipes.
- **[Issues](https://github.com/getkirby/kirby/issues)** Report bugs and other problems.
- **[Feedback](https://feedback.getkirby.com)** You have an idea for Kirby? Share it.
- **[Forum](https://forum.getkirby.com)** Whenever you get stuck, don't hesitate to reach out for questions and support.
- **[Discord](https://chat.getkirby.com)** Hang out and meet the community.
- **[Mastodon](https://mastodon.social/@getkirby)** Spread the word.
- **[Instagram](https://www.instagram.com/getkirby/)** Share your creations: #madewithkirby.
---
- [nuxt-kql](https://nuxt-kql.jhnn.dev): A Nuxt 3 module for KQL.
## License
[MIT](./LICENSE) License © 2020-2023 [Bastian Allgeier](https://getkirby.com)
[MIT](./LICENSE) License © 2020-2022 [Bastian Allgeier](https://getkirby.com)