Skip to content

Commit 2c7788c

Browse files
committed
Add comments to config
1 parent 5b366d6 commit 2c7788c

File tree

2 files changed

+102
-32
lines changed

2 files changed

+102
-32
lines changed

README.md

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,72 @@ php artisan vendor:publish --tag="laravel-speculation-rules-api-config"
2828
This is the contents of the published config file:
2929

3030
```php
31+
<?php
32+
3133
return [
34+
/*
35+
|--------------------------------------------------------------------------
36+
| Default Eagerness
37+
|--------------------------------------------------------------------------
38+
|
39+
| This value is the default eagerness for the prerender and prefetch rules.
40+
| You can set it to 'eager', 'moderate' or 'conservative'.
41+
|
42+
*/
43+
44+
'default_eagerness' => 'moderate',
45+
46+
/*
47+
|--------------------------------------------------------------------------
48+
| Prerender Rules
49+
|--------------------------------------------------------------------------
50+
|
51+
| Here you may specify custom prerender rules for the application.
52+
|
53+
*/
54+
3255
'prerender' => [
33-
[
34-
//
35-
],
56+
// [
57+
// 'source' => 'list',
58+
// 'urls' => ['page-1', 'page-2'],
59+
// 'eagerness' => 'moderate',
60+
// ],
61+
// // parameter usage example
62+
// [
63+
// ['href_matches' => '/page-3/*'],
64+
// ['not' => ['href_matches' => '/page-3/*/*']],
65+
// ],
3666
],
67+
68+
/*
69+
|--------------------------------------------------------------------------
70+
| Prefetch Rules
71+
|--------------------------------------------------------------------------
72+
|
73+
| Here you may specify custom prefetch rules for the application.
74+
|
75+
*/
76+
3777
'prefetch' => [
38-
[
39-
//
40-
],
78+
// [
79+
// 'urls' => ['page-4'],
80+
// 'referrer_policy' => 'no-referrer',
81+
// 'eagerness' => 'moderate',
82+
// ],
4183
],
84+
4285
];
4386
```
4487

45-
Add the following Blade directive before the end `body` tag in your template.
88+
Add the following Blade directive inside the `head` tag.
4689

4790
```php
4891
<html>
92+
<head>
93+
<!-- ... -->
94+
@speculationRulesApi
95+
</head>
4996
...
50-
<body>
51-
...
52-
@speculationRulesApi
53-
</body>
5497
</html>
5598
```
5699

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

103146
```php
104147
return [
148+
149+
// ...
150+
105151
'prerender' => [
106152
[
107153
'source' => 'list',
108154
'urls' => ['page-1'],
109155
'eagerness' => 'moderate',
110156
],
111157
],
158+
112159
'prefetch' => [
113160
[
114161
'urls' => ['page-2'],
115162
'referrer_policy' => 'no-referrer',
116163
'eagerness' => 'moderate',
117164
],
118165
],
166+
119167
];
120168
```
121169

config/speculation-rules-api.php

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,55 @@
22

33
return [
44

5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Eagerness
8+
|--------------------------------------------------------------------------
9+
|
10+
| This value is the default eagerness for the prerender and prefetch rules.
11+
| You can set it to 'eager', 'moderate' or 'conservative'.
12+
|
13+
*/
14+
515
'default_eagerness' => 'moderate',
616

17+
/*
18+
|--------------------------------------------------------------------------
19+
| Prerender Rules
20+
|--------------------------------------------------------------------------
21+
|
22+
| Here you may specify custom prerender rules for the application.
23+
|
24+
*/
25+
726
'prerender' => [
8-
// [
9-
// 'source' => 'list',
10-
// 'urls' => ['page-1', 'page-2'],
11-
// 'eagerness' => 'moderate',
12-
// ],
13-
// // parameter usage example
14-
// [
15-
// [
16-
// 'href_matches' => '/page-3/*'
17-
// ],
18-
// [
19-
// 'not' => [
20-
// 'href_matches' => '/page-3/*/*'
21-
// ]
22-
// ],
23-
// ],
27+
// [
28+
// 'source' => 'list',
29+
// 'urls' => ['page-1', 'page-2'],
30+
// 'eagerness' => 'moderate',
31+
// ],
32+
// // parameter usage example
33+
// [
34+
// ['href_matches' => '/page-3/*'],
35+
// ['not' => ['href_matches' => '/page-3/*/*']],
36+
// ],
2437
],
2538

39+
/*
40+
|--------------------------------------------------------------------------
41+
| Prefetch Rules
42+
|--------------------------------------------------------------------------
43+
|
44+
| Here you may specify custom prefetch rules for the application.
45+
|
46+
*/
47+
2648
'prefetch' => [
27-
// [
28-
// 'urls' => ['page-4'],
29-
// 'referrer_policy' => 'no-referrer',
30-
// 'eagerness' => 'moderate',
31-
// ],
49+
// [
50+
// 'urls' => ['page-4'],
51+
// 'referrer_policy' => 'no-referrer',
52+
// 'eagerness' => 'moderate',
53+
// ],
3254
],
3355

3456
];

0 commit comments

Comments
 (0)