File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ protected function metaArray(): array
121121 public const TAG_TYPE_MAP = [
122122 [
123123 'tag ' => 'title ' ,
124+ 'priority ' => true ,
124125 'tags ' => [
125126 'title '
126127 ]
@@ -221,6 +222,7 @@ public function snippetData(?array $raw = null): array
221222 'tag ' => $ tag ['tag ' ],
222223 'attributes ' => $ value ,
223224 'content ' => null ,
225+ 'priority ' => $ tag ['priority ' ] ?? false ,
224226 ];
225227 continue ;
226228 }
@@ -234,6 +236,7 @@ public function snippetData(?array $raw = null): array
234236 $ tag ['attributes ' ]['content ' ] => $ value ,
235237 ] : null ,
236238 'content ' => !isset ($ tag ['attributes ' ]) ? $ value : null ,
239+ 'priority ' => $ tag ['priority ' ] ?? false ,
237240 ];
238241 }
239242
Original file line number Diff line number Diff line change @@ -71,7 +71,11 @@ public function toString(): string
7171
7272 $ root = $ doc ->createElementNS ('http://www.sitemaps.org/schemas/sitemap/0.9 ' , 'urlset ' );
7373 $ root ->setAttributeNS ('http://www.w3.org/2000/xmlns/ ' , 'xmlns:xhtml ' , 'http://www.w3.org/1999/xhtml ' );
74- $ root ->setAttribute ('seo-version ' , App::plugin ('tobimori/seo ' )->version ());
74+
75+ // version can be null when installing branches during development
76+ if ($ version = App::plugin ('tobimori/seo ' )->version ()) {
77+ $ root ->setAttribute ('seo-version ' , $ version );
78+ }
7579
7680 foreach ($ this as $ url ) {
7781 $ root ->appendChild ($ url ->toDOMNode ($ doc ));
Original file line number Diff line number Diff line change 88
99$ tags = $ page ->metadata ()->snippetData ();
1010
11+ // if we're using slots, the user wants to output priority tags such as <title>
12+ // before their stylesheet, script, etc. tags
13+ if (isset ($ slot )) {
14+ foreach (array_filter ($ tags , fn ($ tag ) => $ tag ['priority ' ]) as $ tag ) {
15+ echo Html::tag ($ tag ['tag ' ], $ tag ['content ' ] ?? null , $ tag ['attributes ' ] ?? []) . PHP_EOL ;
16+ }
17+
18+ echo $ slot ;
19+
20+ $ tags = array_filter ($ tags , fn ($ tag ) => !$ tag ['priority ' ]);
21+ }
22+
23+ // then output other tags as normal
24+ // this is unfiltered if slots is not set.
1125foreach ($ tags as $ tag ) {
1226 echo Html::tag ($ tag ['tag ' ], $ tag ['content ' ] ?? null , $ tag ['attributes ' ] ?? []) . PHP_EOL ;
1327}
You can’t perform that action at this time.
0 commit comments