Skip to content

Commit

Permalink
Add comments to config
Browse files Browse the repository at this point in the history
  • Loading branch information
authanram committed Aug 9, 2024
1 parent 5b366d6 commit 2c7788c
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 32 deletions.
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,72 @@ php artisan vendor:publish --tag="laravel-speculation-rules-api-config"
This is the contents of the published config file:

```php
<?php

return [
/*
|--------------------------------------------------------------------------
| Default Eagerness
|--------------------------------------------------------------------------
|
| This value is the default eagerness for the prerender and prefetch rules.
| You can set it to 'eager', 'moderate' or 'conservative'.
|
*/

'default_eagerness' => 'moderate',

/*
|--------------------------------------------------------------------------
| Prerender Rules
|--------------------------------------------------------------------------
|
| Here you may specify custom prerender rules for the application.
|
*/

'prerender' => [
[
//
],
// [
// 'source' => 'list',
// 'urls' => ['page-1', 'page-2'],
// 'eagerness' => 'moderate',
// ],
// // parameter usage example
// [
// ['href_matches' => '/page-3/*'],
// ['not' => ['href_matches' => '/page-3/*/*']],
// ],
],

/*
|--------------------------------------------------------------------------
| Prefetch Rules
|--------------------------------------------------------------------------
|
| Here you may specify custom prefetch rules for the application.
|
*/

'prefetch' => [
[
//
],
// [
// 'urls' => ['page-4'],
// 'referrer_policy' => 'no-referrer',
// 'eagerness' => 'moderate',
// ],
],

];
```

Add the following Blade directive before the end `body` tag in your template.
Add the following Blade directive inside the `head` tag.

```php
<html>
<head>
<!-- ... -->
@speculationRulesApi
</head>
...
<body>
...
@speculationRulesApi
</body>
</html>
```

Expand Down Expand Up @@ -102,20 +145,25 @@ Alternatively you can utilize the Speculation Rules API through the package conf

```php
return [

// ...

'prerender' => [
[
'source' => 'list',
'urls' => ['page-1'],
'eagerness' => 'moderate',
],
],

'prefetch' => [
[
'urls' => ['page-2'],
'referrer_policy' => 'no-referrer',
'eagerness' => 'moderate',
],
],

];
```

Expand Down
64 changes: 43 additions & 21 deletions config/speculation-rules-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,55 @@

return [

/*
|--------------------------------------------------------------------------
| Default Eagerness
|--------------------------------------------------------------------------
|
| This value is the default eagerness for the prerender and prefetch rules.
| You can set it to 'eager', 'moderate' or 'conservative'.
|
*/

'default_eagerness' => 'moderate',

/*
|--------------------------------------------------------------------------
| Prerender Rules
|--------------------------------------------------------------------------
|
| Here you may specify custom prerender rules for the application.
|
*/

'prerender' => [
// [
// 'source' => 'list',
// 'urls' => ['page-1', 'page-2'],
// 'eagerness' => 'moderate',
// ],
// // parameter usage example
// [
// [
// 'href_matches' => '/page-3/*'
// ],
// [
// 'not' => [
// 'href_matches' => '/page-3/*/*'
// ]
// ],
// ],
// [
// 'source' => 'list',
// 'urls' => ['page-1', 'page-2'],
// 'eagerness' => 'moderate',
// ],
// // parameter usage example
// [
// ['href_matches' => '/page-3/*'],
// ['not' => ['href_matches' => '/page-3/*/*']],
// ],
],

/*
|--------------------------------------------------------------------------
| Prefetch Rules
|--------------------------------------------------------------------------
|
| Here you may specify custom prefetch rules for the application.
|
*/

'prefetch' => [
// [
// 'urls' => ['page-4'],
// 'referrer_policy' => 'no-referrer',
// 'eagerness' => 'moderate',
// ],
// [
// 'urls' => ['page-4'],
// 'referrer_policy' => 'no-referrer',
// 'eagerness' => 'moderate',
// ],
],

];

0 comments on commit 2c7788c

Please sign in to comment.