1313use Statikbe \FilamentFlexibleContentBlockPages \Facades \FilamentFlexibleContentBlockPages ;
1414use Statikbe \FilamentFlexibleContentBlockPages \Models \Page ;
1515use Statikbe \FilamentFlexibleContentBlockPages \Services \Enum \SitemapGeneratorMethod ;
16+ use Statikbe \FilamentFlexibleContentBlocks \ContentBlocks \CallToActionBlock ;
1617use Statikbe \FilamentFlexibleContentBlocks \FilamentFlexibleBlocksConfig ;
1718use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasCode ;
1819use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasParent ;
@@ -95,8 +96,10 @@ protected function addPageToSitemap(Page $page): void
9596 // Get canonical URL
9697 $ canonicalUrl = $ page ->getViewUrl ($ this ->canonicalLocale );
9798
99+ $ lastModified = $ page ->{$ page ->getUpdatedAtColumn ()} ?? $ page ->{$ page ->getCreatedAtColumn ()};
100+
98101 $ urlTag = $ this ->addToSitemap ($ canonicalUrl ,
99- $ page -> updated_at ?? $ page -> created_at ,
102+ $ lastModified ,
100103 $ this ->calculatePriority ($ page ),
101104 $ this ->calculateChangeFrequency ($ page ),
102105 onlyCreate: true );
@@ -183,8 +186,7 @@ protected function addCustomUrls(): void
183186
184187 protected function getLinkableModels (): array
185188 {
186- // 'general' is just random block to trigger fetching the default configuration:
187- $ ctaModels = FilamentFlexibleBlocksConfig::getCallToActionModels ('general ' );
189+ $ ctaModels = FilamentFlexibleBlocksConfig::getCallToActionModels (CallToActionBlock::class);
188190 $ menuModels = FilamentFlexibleContentBlockPages::config ()->getMenuLinkableModels ();
189191
190192 // Merge and remove duplicates
@@ -194,12 +196,12 @@ protected function getLinkableModels(): array
194196 protected function calculatePriority (HasParent &HasCode $ page ): float
195197 {
196198 // Homepage gets highest priority
197- if ($ page ->code === Page::HOME_PAGE ) {
199+ if (property_exists ( $ page , ' code ' ) && $ page ->code === Page::HOME_PAGE ) {
198200 return 1.0 ;
199201 }
200202
201203 // Parent pages get higher priority than children
202- if (! $ page ->parent_id ) {
204+ if (property_exists ( $ page , ' parent_id ' ) && ! $ page ->parent_id ) {
203205 return 0.8 ;
204206 }
205207
@@ -209,7 +211,8 @@ protected function calculatePriority(HasParent&HasCode $page): float
209211
210212 protected function calculateChangeFrequency (Model $ page ): string
211213 {
212- $ daysSinceUpdate = $ page ->updated_at ? $ page ->updated_at ->diffInDays (Carbon::now ()) : 365 ;
214+ $ updatedAt = $ page ->{$ page ->getUpdatedAtColumn ()};
215+ $ daysSinceUpdate = $ updatedAt ? $ updatedAt ->diffInDays (Carbon::now ()) : 365 ;
213216
214217 if ($ daysSinceUpdate < 7 ) {
215218 return Url::CHANGE_FREQUENCY_WEEKLY ;
0 commit comments