-
Notifications
You must be signed in to change notification settings - Fork 11
/
future2021.php
50 lines (41 loc) · 1.53 KB
/
future2021.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
/**
* Future2021 Theme
*
* Class Future2021
*
* @category Extensions
* @package Grav\Theme
* @author Pedro Moreno <https://github.com/pmoreno-rodriguez>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://github.com/pmoreno-rodriguez/grav-theme-future2021
*/
class Future2021 extends Theme
{
public function onTwigSiteVariables ()
{
$themeConfig = $this->config->get('themes.future2021');
// Add custom.css and custom.js assets if they exists
if (isset($themeConfig['custom_css']) && $themeConfig['custom_css'] && file_exists(__DIR__ . '/assets/css/custom.css')) {
$this->grav['assets']->addCss('theme://assets/css/custom.css', ['priority' => 5]);
}
if (isset($themeConfig['custom_js']) && $themeConfig['custom_js'] && file_exists(__DIR__ . '/assets/js/custom.js')) {
$this->grav['assets']->addJs('theme://assets/js/custom.js', ['group' => 'bottom', 'priority' => 15]);
}
}
public function onShortcodeHandlers()
{
$this->grav['shortcode']->registerAllShortcodes(__DIR__ . '/shortcodes');
}
// Add images to twig template paths to allow inclusion of SVG files
public function onTwigLoader()
{
$theme_paths = Grav::instance()['locator']->findResources('theme://images');
foreach($theme_paths as $images_path) {
$this->grav['twig']->addPath($images_path, 'images');
}
}
}