feat: reworked the template structure
This commit is contained in:
parent
c607d57221
commit
c9808f90f8
24 changed files with 216 additions and 80 deletions
|
@ -6,8 +6,6 @@ class Post implements ArrayAccess {
|
|||
private $content_html;
|
||||
private $content_markdown;
|
||||
|
||||
private $site_defaults;
|
||||
|
||||
public $data;
|
||||
|
||||
public $html_data;
|
||||
|
@ -66,14 +64,12 @@ class Post implements ArrayAccess {
|
|||
|
||||
$this->content_html = null;
|
||||
$this->content_markdown = null;
|
||||
|
||||
$this->site_defaults = $site_defaults;
|
||||
|
||||
if(!isset($post_data) or !isset($post_data['id'])) {
|
||||
$post_data = $this->_generate_404($post_data);
|
||||
}
|
||||
|
||||
$data = $post_data;
|
||||
$data = array_merge($site_defaults, $post_data);
|
||||
|
||||
if($data['path'] == '') {
|
||||
$data['path'] = '/';
|
||||
|
@ -127,11 +123,7 @@ class Post implements ArrayAccess {
|
|||
return $this->data[$name];
|
||||
}
|
||||
|
||||
if(is_null($this->site_defaults)) {
|
||||
throw new RuntimeException("Post site defaults have not been set properly!");
|
||||
}
|
||||
|
||||
return $this->site_defaults[$name] ?? null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function offsetGet($offset) : mixed {
|
||||
|
@ -141,9 +133,6 @@ class Post implements ArrayAccess {
|
|||
if(isset($this->data[$offset])) {
|
||||
return true;
|
||||
}
|
||||
if(isset($this->site_defaults[$offset])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !is_null($this->offsetGet($offset));
|
||||
}
|
||||
|
@ -179,7 +168,7 @@ class Post implements ArrayAccess {
|
|||
}
|
||||
|
||||
public function to_array($options = []) {
|
||||
$out_data = array_merge($this->site_defaults, $this->data);
|
||||
$out_data = $this->data;
|
||||
|
||||
if(isset($options['markdown'])) {
|
||||
$out_data['markdown'] = $this->get_markdown();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue