You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,8 @@ Here are scenarios where the Kirby Headless plugin is particularly useful:
34
34
Detailed instructions on how to use these features can be found in the [usage](#usage) section.
35
35
36
36
> [!TIP]
37
-
> Kirby Headless overrides the global Kirby routes for the [templates](#templates) feature. To opt-out, head over to the [setup](#setup) section.
37
+
> Kirby Headless doesn't interfere with Kirby's default routing. You can install it without affecting your existing Kirby site.
38
+
> To use the [JSON templates](#templates) feature, opt-in to [override the gobal routing](#setup).
38
39
39
40
## Requirements
40
41
@@ -57,20 +58,25 @@ Download and copy this repository to `/site/plugins/kirby-headless`.
57
58
58
59
## Setup
59
60
60
-
By default, the plugin will override the global Kirby routes and add its [own global routes](./src/extensions/routes.php) and [API routes for KQL](./src/extensions/api.php).
61
+
> [!TIP]
62
+
> If you don't intend to use the [JSON templates](#templates) feature, you can skip this section!
63
+
64
+
By default, the plugin doesn't interfere with Kirby's default routing, it just adds API routes like [for KQL](./src/extensions/api.php).
61
65
62
-
If you prefer the traditional Kirby frontend and only need headless functionality like KQL, you can disable the global routes in your `config.php`:
66
+
To transform Kirby from a traditional frontend to a truly headless-only CMS, you have to opt-in to custom global routing in your `config.php`:
63
67
64
68
```php
65
69
# /site/config/config.php
66
70
return [
67
71
'headless' => [
68
-
// Disable overriding the global routes
69
-
'routes' => false
72
+
// Enable returning Kirby templates as JSON
73
+
'globalRoutes' => true
70
74
]
71
75
];
72
76
```
73
77
78
+
This will make all page templates return JSON instead of HTML by [defining global routes](./src/extensions/routes.php).
79
+
74
80
## Usage
75
81
76
82
### KirbyQL
@@ -180,10 +186,10 @@ return [
180
186
181
187
### Templates
182
188
183
-
Create templates just like you normally would in any Kirby project. Instead of writing HTML, we build arrays and encode them to JSON. The internal route handler will add the correct content type and also handles caching (if enabled).
189
+
Write templates as you would in any other Kirby project. But instead of returning HTML, they return JSON. The internal route handler adds the correct content type and also handles caching (if enabled).
184
190
185
-
> [!TIP]
186
-
> Kirby Headless overrides the global Kirby routes for this feature. To opt-out, set the `headless.routes` option to `false` in your `config.php`.
191
+
> [!INFO]
192
+
> Kirby Headless doesn't interfere with Kirby's default routing. To opt-in, follow the [setup instructions](#setup).
0 commit comments