diff --git a/app/themes/default/config.php b/app/themes/default/config.php new file mode 100644 index 0000000..d960444 --- /dev/null +++ b/app/themes/default/config.php @@ -0,0 +1,6 @@ + false +]; diff --git a/app/themes/default/functions.php b/app/themes/default/functions.php index 98f2fb6..d7e4a2d 100644 --- a/app/themes/default/functions.php +++ b/app/themes/default/functions.php @@ -13,6 +13,27 @@ return [ : $icons[$file->getExtension()] ?? 'fas fa-file'; return ""; - }) + }), + + /** + * Retrieve an item from the theme config. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + new TwigFunction('config', function (string $key, $default = null) { + $config = require __DIR__ . '/config.php'; + + foreach (explode('.', $key) as $k) { + if (! isset($config[$k])) { + return $default; + } + $config = $config[$k]; + } + + return $config; + }), ] ]; diff --git a/app/themes/default/index.twig b/app/themes/default/index.twig index ff585c7..adbd24d 100644 --- a/app/themes/default/index.twig +++ b/app/themes/default/index.twig @@ -6,8 +6,8 @@