Create options and hook to load Bootstrap assets.

This commit is contained in:
2026-04-17 02:47:54 +10:00
parent 6f42e297ad
commit 5e743aff41

View File

@@ -14,6 +14,35 @@
Kirby::plugin(
name: "hobbyhome/bootstrap",
extends: [
"options" => [
"assets" => [
"css" => [
100 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/bootstrap/css/bootstrap" . r(!option("debug"), ".min") . ".css", true),
],
"jsHeader" => [
100 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/bootstrap/js/bootstrap.bundle" . r(!option("debug"), ".min") . ".js", true),
],
],
],
"hooks" => [
/**
* To add this hook to a plugin, change the option() call to use the plugins name.
*
* @version 1.0
*/
"hobbyhome.getAssets" => function ($files = [], $type = "css") {
foreach (option("hobbyhome.bootstrap.assets.{$type}", []) as $order => $file) {
# Make sure no other file exists with the current sort order index.
while (isset($files[$order])) {
$order++;
}
$files[$order] = $file;
}
return $files;
},
],
],
info: [
"authors" => [[
@@ -23,5 +52,6 @@ Kirby::plugin(
]],
"license" => "AGPL-3.0-only",
"version" => "0.0.0",
# "bootstrap" => "5.3.8",
],
);