Skip to content

Commit 3a8048c

Browse files
author
Tom Schlick
committed
default links load
1 parent dab633c commit 3a8048c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

config/server-push.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
return [
44

5+
// Include assets you want to link on every page load here.
56
'default_links' => [
6-
77
'styles' => [
88

99
],
@@ -15,7 +15,6 @@
1515
'images' => [
1616

1717
],
18-
1918
],
2019

2120
];

src/ServiceProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,22 @@ public function register()
3030
return $this->app->make(HttpPush::class);
3131
});
3232
}
33+
34+
/**
35+
* Load the default links from the config.
36+
*/
37+
protected function registerDefaultLinks()
38+
{
39+
$this->mergeConfigFrom(__DIR__ . '/../config/server-push.php', 'server-push');
40+
41+
$instance = app('server-push');
42+
43+
foreach (config('server-push.default_links', []) as $type => $paths) {
44+
$type = rtrim($type, 's');
45+
foreach ($paths as $path) {
46+
$instance->queueResource($path, $type);
47+
}
48+
}
49+
}
50+
3351
}

0 commit comments

Comments
 (0)