Skip to content

Commit

Permalink
Add cachebusting to custom panel css
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Sep 13, 2019
1 parent 8148e09 commit 9bb2a44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Cms/Panel.php
Expand Up @@ -24,6 +24,18 @@
*/
class Panel
{
public static function customCss(App $kirby)
{
if ($css = $kirby->option('panel.css')) {
$asset = asset($css);

if ($asset->exists() === true) {
return $asset->url() . '?' . $asset->modified();
}
}

return false;
}

/**
* Links all dist files in the media folder
Expand Down Expand Up @@ -85,6 +97,7 @@ public static function render(App $kirby)
'kirby' => $kirby,
'config' => $kirby->option('panel'),
'assetUrl' => $kirby->url('media') . '/panel/' . $kirby->versionHash(),
'customCss' => static::customCss($kirby),
'pluginCss' => $plugins->url('css'),
'pluginJs' => $plugins->url('js'),
'panelUrl' => $uri->path()->toString(true) . '/',
Expand Down
4 changes: 2 additions & 2 deletions views/panel.php
Expand Up @@ -10,8 +10,8 @@
<link rel="stylesheet" href="<?= $assetUrl ?>/css/app.css">
<link rel="stylesheet" href="<?= $pluginCss ?>">

<?php if (isset($config['css'])) : ?>
<link rel="stylesheet" href="<?= Url::to($config['css']) ?>">
<?php if ($customCss) : ?>
<link rel="stylesheet" href="<?= $customCss ?>">
<?php endif ?>

<link rel="apple-touch-icon" href="<?= $assetUrl ?>/apple-touch-icon.png" />
Expand Down

0 comments on commit 9bb2a44

Please sign in to comment.