File tree Expand file tree Collapse file tree 4 files changed +40
-1
lines changed
Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1313 type : pages
1414 layout : cards
1515 status : published
16+ flip : true
1617 image :
1718 cover : true
1819 ratio : 16/9
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Kirby \Cms \Block ;
4+ use Kirby \Cms \Page ;
5+ use Kirby \Toolkit \Str ;
6+
7+ class ArticlePage extends Page
8+ {
9+ public function abstract (): string
10+ {
11+ $ abstract = $ this ->getAbstract ();
12+
13+ return match (true ) {
14+ !empty ($ abstract ) => $ abstract ,
15+ $ this ->subtitle ()->isNoEmpty () => $ this ->subtitle (),
16+ default => $ this ->title (),
17+ };
18+ }
19+
20+ protected function getAbstract (): null |string
21+ {
22+ if ($ this ->blocks ()->isEmpty ()) {
23+ return null ;
24+ }
25+
26+ $ text = $ this
27+ ->blocks ()
28+ ->toBlocks ()
29+ ->filter (fn ($ block ) => $ block ->type () === 'text ' );
30+
31+ if ($ text ->isEmpty ()) {
32+ return null ;
33+ }
34+
35+ return Str::excerpt ($ text );
36+ }
37+ }
Original file line number Diff line number Diff line change 1212 {{ $article -> title () } }
1313 </div >
1414 <div class =" font-thin font-inter text-gray-600" >
15- {{ $article -> subtitle () } }
15+ {{ $article -> abstract () } }
1616 </div >
1717 </div >
1818 <img src =" {{ $article -> image ()-> url () } }" alt =" {{ $article -> title () } }" class =" w-full sm:w-32 sm:h-28 object-cover shadow-md sm:ml-6 mt-3 sm:mt-0" >
Original file line number Diff line number Diff line change 2020 </div >
2121 <div class =" font-thin font-inter text-gray-600" >
2222 {!! $highlightedSubtitle ! !}
23+ {{ $article -> greatings () } }
2324 </div >
2425 </div >
2526 @empty (! $article -> image () )
You can’t perform that action at this time.
0 commit comments