bnomei / kirby3-fingerprint

File Method and css/js helper to add hash to files
https://forum.getkirby.com/t/kirby-3-fingerprint-asset-cachebuster/23576
MIT License
37 stars 3 forks source link

Echo only URL of the file with fingerprint #12

Closed christianschley closed 4 years ago

christianschley commented 4 years ago

Hi,

im testing your plugin and it works fine, but i have one problem currently:

In the header i use: <?= Bnomei\Fingerprint::css('/assets/css/main.min.css') ?> which creates <link href="http:/www.mydomain.test/assets/css/main.min.css?v=1575271772" rel="stylesheet">

But i am trying to preload the CSS file with <link rel="preload" href="<?= url('/assets/css/main.min.css') ?>" as="style"> which leads to an waring in chrome because the version is missing...

How can i echo just the URL of my css file with your plugin including the version number?

bnomei commented 4 years ago

yes the readme was confusing in that regard. i added a new helper for the raw url as Fingerprint::url() and updated the readme.

echo Bnomei\Fingerprint::css('/assets/css/index.css');
// <style> element with https://../assets/css/index.css?v=1203291283

echo Bnomei\Fingerprint::js('/assets/js/index.min.js');
// <link> element https://../assets/js/index.min.js?v=1203291283

echo Bnomei\Fingerprint::url('/assets/css/index.css');
// raw url https://../assets/css/index.css?v=1203291283
bnomei commented 4 years ago
<link rel="preload" href="<?= Bnomei\Fingerprint::url('/assets/css/main.min.css') ?>" as="style">
bnomei commented 4 years ago

https://github.com/bnomei/kirby3-fingerprint/releases/tag/v3.0.5