Skip to content

Commit 85cd86a

Browse files
refactor!: use KIRBY_CONTENT_API_SLUG env var
1 parent 90c139f commit 85cd86a

File tree

8 files changed

+12
-21
lines changed

8 files changed

+12
-21
lines changed

.env.development.example

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ KIRBY_CACHE=false
66
KIRBY_DEV_HOSTNAME=127.0.0.1
77
KIRBY_DEV_PORT=8080
88
KIRBY_DEV_PROTOCOL=http
9-
VITE_DEV_PORT=3000
9+
KIRBY_CONTENT_API_SLUG=app
1010

11+
VITE_DEV_PORT=3000
1112
VITE_STALE_WHILE_REVALIDATE=false
12-
13-
# API slug to fetch JSON-encoded page data from
14-
CONTENT_API_SLUG=app

.env.production.example

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ KIRBY_CACHE=false
66
KIRBY_DEV_HOSTNAME=127.0.0.1
77
KIRBY_DEV_PORT=8080
88
KIRBY_DEV_PROTOCOL=http
9-
VITE_DEV_PORT=3000
9+
KIRBY_CONTENT_API_SLUG=app
1010

11+
VITE_DEV_PORT=3000
1112
VITE_STALE_WHILE_REVALIDATE=false
12-
13-
# API slug to fetch JSON-encoded page data from
14-
CONTENT_API_SLUG=app

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ For example, setting `KIRBY_CACHE` to `true` is useful in production environment
265265

266266
To change the API slug to fetch JSON-encoded page data from, set
267267

268-
- `CONTENT_API_SLUG` to a value of your liking (defaults to `spa`). It can even be left empty to omit a slug altogether!
268+
- `KIRBY_CONTENT_API_SLUG` to a value of your liking (defaults to `app`). It can even be left empty to omit a slug altogether!
269269

270270
> You can't use Kirby's internal API slug (defaults to `api`). If you insist on using `api` for _your_ content endpoint, you can rename Kirby's by adding a `KIRBY_API_SLUG` key and set it to something other than `api`.
271271

site/plugins/kirby-vue-kit/classes/VueKit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function preloadJson(string $name): string
111111

112112
return Html::tag('link', '', [
113113
'rel' => 'preload',
114-
'href' => $base . '/' . Url::path(env('CONTENT_API_SLUG')) . '/' . $name . '.json',
114+
'href' => $base . '/' . Url::path(env('KIRBY_CONTENT_API_SLUG')) . '/' . $name . '.json',
115115
'as' => 'fetch',
116116
'type' => 'application/json',
117117
'crossorigin' => 'anonymous'

site/plugins/kirby-vue-kit/routes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Kirby\Http\Response;
55
use JohannSchopplich\VueKit\Page;
66

7-
$apiLocation = Url::path(env('CONTENT_API_SLUG', ''), false, true);
7+
$apiLocation = Url::path(env('KIRBY_CONTENT_API_SLUG', ''), false, true);
88

99
return [
1010
/**

src/composables/useLanguages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Indicates a multi-language setup
33
*/
4-
const isMultilang = import.meta.env.VITE_MULTILANG === "true";
4+
const isMultilang = import.meta.env.KIRBY_MULTILANG === "true";
55

66
/**
77
* Current language code

src/modules/kirbytext.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let router;
22
const origin = import.meta.env.DEV
3-
? import.meta.env.VITE_BACKEND_URL
3+
? `${process.env.KIRBY_DEV_PROTOCOL}://${process.env.KIRBY_DEV_HOSTNAME}:${process.env.KIRBY_DEV_PORT}`
44
: window.location.origin;
55

66
/**

vite.config.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@ import Vue from "@vitejs/plugin-vue";
44
import Components from "unplugin-vue-components/vite";
55

66
const root = "src";
7+
const envPrefix = ["VITE_", "KIRBY_"];
78

89
export default defineConfig(({ mode }) => {
9-
Object.assign(
10-
process.env,
11-
loadEnv(mode, process.cwd(), ["VITE_", "KIRBY_", "CONTENT_"])
12-
);
13-
14-
process.env.VITE_BACKEND_URL = `${process.env.KIRBY_DEV_PROTOCOL}://${process.env.KIRBY_DEV_HOSTNAME}:${process.env.KIRBY_DEV_PORT}`;
15-
process.env.VITE_BACKEND_API_SLUG = process.env.CONTENT_API_SLUG;
16-
process.env.VITE_MULTILANG = process.env.KIRBY_MULTILANG;
10+
Object.assign(process.env, loadEnv(mode, process.cwd(), envPrefix));
1711

1812
return defineConfig({
1913
root,
2014
base: mode === "development" ? "/" : "/dist/",
15+
envPrefix,
2116

2217
resolve: {
2318
alias: {

0 commit comments

Comments
 (0)