schnti / kirby3-cachebuster

11 stars 5 forks source link

Multisite Setup? #7

Open demlak opened 3 years ago

demlak commented 3 years ago

Hey.. i just changed my setup for multisite use.. (cookbook recipe / Forum) now there is a problem of integrating asset folder.. any idea on this?

thx a lot

demlak commented 3 years ago

fixed it:

<?php

defined('DS') or define('DS', '/');

Kirby::plugin('schnti/cachebuster', [
        'options'    => [
                'active' => true
        ],
        'components' => [
                'css' => function ($kirby, $url) {

                        if ($kirby->option('schnti.cachebuster.active')) {

                                return dirname($url) . '/' . F::name($url) . '.' . F::modified(Url::path($url)) . '.css';

                        } else {
                                return $url;
                        }
                },
                'js'  => function ($kirby, $url) {

                        if ($kirby->option('schnti.cachebuster.active')) {

                                return dirname($url) . '/' . F::name($url) . '.' . F::modified(Url::path($url)) . '.js';

                        } else {
                                return $url;
                        }
                }
        ]
]);