|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hyde\Framework\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Hyde\Framework\Helpers\Features; |
|
6
|
|
|
use Hyde\Framework\Helpers\Meta; |
|
7
|
|
|
use Hyde\Framework\Hyde; |
|
8
|
|
|
use Hyde\Framework\Models\Metadata\MetadataBag; |
|
9
|
|
|
use Hyde\Framework\Services\RssFeedService; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @see \Hyde\Framework\Testing\Models\SiteTest |
|
13
|
|
|
*/ |
|
14
|
|
|
final class Site |
|
15
|
|
|
{ |
|
16
|
|
|
public ?string $url; |
|
17
|
|
|
public ?string $name; |
|
18
|
|
|
public ?string $language; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->url = self::url(); |
|
23
|
|
|
$this->name = self::name(); |
|
24
|
|
|
$this->language = self::language(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public static function url(): ?string |
|
28
|
|
|
{ |
|
29
|
|
|
return config('site.url'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public static function name(): ?string |
|
33
|
|
|
{ |
|
34
|
|
|
return config('site.name'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function language(): ?string |
|
38
|
|
|
{ |
|
39
|
|
|
return config('site.language'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @todo Remove duplicate metadata from page |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function metadata(): MetadataBag |
|
46
|
|
|
{ |
|
47
|
|
|
$metadataBag = new MetadataBag(); |
|
48
|
|
|
|
|
49
|
|
|
foreach (config('hyde.meta', []) as $item) { |
|
50
|
|
|
$metadataBag->add($item); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if (Features::sitemap()) { |
|
54
|
|
|
$metadataBag->add(Meta::link('sitemap', Hyde::url('sitemap.xml'), [ |
|
55
|
|
|
'type' => 'application/xml', 'title' => 'Sitemap', |
|
56
|
|
|
])); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if (Features::rss()) { |
|
60
|
|
|
$metadataBag->add(Meta::link('alternate', Hyde::url(RssFeedService::getDefaultOutputFilename()), [ |
|
61
|
|
|
'type' => 'application/rss+xml', 'title' => RssFeedService::getDescription(), |
|
62
|
|
|
])); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $metadataBag; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|