mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 01:23:32 +09:00
Add Context::addLink() and Context::getLinks() to register HTML header content such as <link rel="preconnect">
This commit is contained in:
parent
ac895d64cb
commit
b951d50841
2 changed files with 27 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ class Context
|
||||||
public $html_footer = '';
|
public $html_footer = '';
|
||||||
public $body_header = '';
|
public $body_header = '';
|
||||||
public $body_class = [];
|
public $body_class = [];
|
||||||
|
public $link_rels = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current page's SEO information.
|
* The current page's SEO information.
|
||||||
|
|
@ -2494,7 +2495,7 @@ class Context
|
||||||
*/
|
*/
|
||||||
public static function getHtmlHeader(): string
|
public static function getHtmlHeader(): string
|
||||||
{
|
{
|
||||||
return self::$_instance->html_header;
|
return self::$_instance->html_header === '' ? '' : (self::$_instance->html_header . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2602,6 +2603,28 @@ class Context
|
||||||
return self::$_instance->html_footer;
|
return self::$_instance->html_footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add <link> such as <link rel="preconnect" href="https://webfonts.example.com" />
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param string $rel
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function addLink(string $url, string $rel): void
|
||||||
|
{
|
||||||
|
self::$_instance->link_rels[$url] = $rel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns added <link> list
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getLinks(): array
|
||||||
|
{
|
||||||
|
return self::$_instance->link_rels;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config file
|
* Get config file
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@
|
||||||
@if (!empty($mobicon_url))
|
@if (!empty($mobicon_url))
|
||||||
<link rel="apple-touch-icon" href="{{ $mobicon_url }}" />
|
<link rel="apple-touch-icon" href="{{ $mobicon_url }}" />
|
||||||
@endif
|
@endif
|
||||||
|
@foreach (Context::getLinks() as $link_url => $link_rel)
|
||||||
|
<link rel="{{ $link_rel }}" href="{{ $link_url }}" />
|
||||||
|
@endforeach
|
||||||
|
|
||||||
<!-- OTHER HEADERS -->
|
<!-- OTHER HEADERS -->
|
||||||
@foreach (Context::getOpenGraphData() as $og_metadata)
|
@foreach (Context::getOpenGraphData() as $og_metadata)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue