diff --git a/README.md b/README.md index a5dc5b5..da8a1d5 100644 --- a/README.md +++ b/README.md @@ -23,21 +23,22 @@ This package uses [auto-discovery](https://laravel.com/docs/5.5/packages#package ## Config -The base path of the assets will be the `public` directory. You can change it within the config file `subresource-integrity`. - -You can also customize the hashing algorithm. Possible algorithms are `sha256`, `sha384` and `sha512`. - -You can publish the config file using +If you want ot make changes in the configuration you can publish the config file using ```sh $ php artisan vendor:publish --provider="Elhebert\SubresourceIntegrity\SriServiceProvider" ``` -## Usage +### Content of the configuration -To avoid having to re-hash the file on every reload, you can use the [laravel-mix-sri](https://github.com/Elhebert/laravel-mix-sri) mix extension. It'll generate new hashes on build and store them in a `mix-sri.json` file. +| key | default value | possible values | +| - | - | - | +| base_path | `base_path('/public')` | | +| algorithm | sha256 | sha256, sha384 and sha512 | +| hashes | `[]` | (see "[How to get a hash](#how-to-get-a-hash)) | +| mix_sri_path | `public_path('mix-sri.json')` | (see "[How to get a hash](#how-to-get-a-hash)) | -The `hash` method will first try to read this file and extract the correspond hash for a given asset file. If it exist, it'll return that value. Otherwise it'll read the content of the asset file and hash it accordingly. +## Usage To only get a hash, use `Sri::hash`: @@ -62,6 +63,7 @@ To generate the HTML for the `integrity` and the `crossorigin` attributes, use ` > ``` + ### Blade directive Two blade directive are available to make your views cleaner: @@ -76,6 +78,45 @@ Use `@assetSri` to generate the `` or ` ``` -You can also use the blade directives for remotes resources. Both are similar for external assets. It'll simply load the asset without the laravel helper. - -```php -@mixSri(http://code.jquery.com/jquery-3.3.1.min.js) -@assetSri(http://code.jquery.com/jquery-3.3.1.min.js) -``` - -will both generate the equivalent of the`