From 5e743aff411a7f1bb5e1e1af609c1b41279c1a92 Mon Sep 17 00:00:00 2001 From: Dreytac Date: Fri, 17 Apr 2026 02:47:54 +1000 Subject: [PATCH] Create options and hook to load Bootstrap assets. --- index.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/index.php b/index.php index b423801..e3b60d9 100644 --- a/index.php +++ b/index.php @@ -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", ], );