4
4
5
5
use Illuminate \Support \Collection as IlluminateCollection ;
6
6
use Illuminate \Support \LazyCollection ;
7
+ use Statamic \Entries \Entry ;
7
8
use Statamic \Facades \Blink ;
8
9
use Statamic \Facades \Collection ;
9
- use Statamic \Facades \Entry ;
10
+ use Statamic \Facades \Entry as EntryFacade ;
10
11
use Statamic \Facades \Taxonomy ;
11
12
use Statamic \SeoPro \Cascade ;
12
13
use Statamic \SeoPro \GetsSectionDefaults ;
@@ -18,6 +19,8 @@ class Sitemap
18
19
19
20
const CACHE_KEY = 'seo-pro.sitemap ' ;
20
21
22
+ private ?string $ domain = null ;
23
+
21
24
public function pages (): array
22
25
{
23
26
return collect ()
@@ -88,6 +91,13 @@ public function paginatedSitemaps(): array
88
91
->all ();
89
92
}
90
93
94
+ public function forDomain (string $ domain ): self
95
+ {
96
+ $ this ->domain = $ domain ;
97
+
98
+ return $ this ;
99
+ }
100
+
91
101
protected function getPages ($ items )
92
102
{
93
103
return $ items
@@ -123,7 +133,7 @@ protected function publishedEntriesQuery()
123
133
->values ()
124
134
->all ();
125
135
126
- return Entry ::query ()
136
+ return EntryFacade ::query ()
127
137
->whereIn ('collection ' , $ collections )
128
138
->whereNotNull ('uri ' )
129
139
->whereStatus ('published ' )
@@ -132,7 +142,15 @@ protected function publishedEntriesQuery()
132
142
133
143
protected function publishedEntries (): LazyCollection
134
144
{
135
- return $ this ->publishedEntriesQuery ()->lazy ();
145
+ return $ this
146
+ ->publishedEntriesQuery ()
147
+ ->lazy ()
148
+ ->unless (
149
+ is_null ($ this ->domain ),
150
+ fn (LazyCollection $ c ) => $ c ->filter (
151
+ fn (Entry $ entry ) => str ($ entry ->permalink )->startsWith ($ this ->domain )
152
+ )
153
+ );
136
154
}
137
155
138
156
protected function publishedEntriesForPage (int $ page , int $ perPage ): IlluminateCollection
0 commit comments