diff --git a/formwork/src/Pages/ContentFile.php b/formwork/src/Pages/ContentFile.php index c7e1ea6e7..3d8eb494b 100644 --- a/formwork/src/Pages/ContentFile.php +++ b/formwork/src/Pages/ContentFile.php @@ -4,6 +4,7 @@ use Formwork\Files\File; use Formwork\Parsers\Yaml; +use Formwork\Utils\Arr; use Formwork\Utils\FileSystem; use UnexpectedValueException; @@ -67,7 +68,7 @@ protected function load(): void [, $frontmatter, $content] = $matches; - $this->frontmatter = Yaml::parse($frontmatter); + $this->frontmatter = Arr::undot(Yaml::parse($frontmatter)); $this->content = str_replace("\r\n", "\n", $content); } diff --git a/formwork/src/Pages/Page.php b/formwork/src/Pages/Page.php index 570ff929a..773912fc6 100644 --- a/formwork/src/Pages/Page.php +++ b/formwork/src/Pages/Page.php @@ -175,11 +175,11 @@ public function __construct( $this->loadFiles(); if ($this->contentFile instanceof ContentFile && !$this->contentFile->isEmpty()) { - $this->data = [ - ...$this->data, - ...$this->contentFile->frontmatter(), - 'content' => $this->contentFile->content(), - ]; + $this->data = array_replace_recursive( + $this->data, + $this->contentFile->frontmatter(), + ['content' => $this->contentFile->content()], + ); } $this->fields->setValues([...$this->data, 'slug' => $this->slug, 'parent' => $this->parent()?->route(), 'template' => $this->template]); @@ -249,7 +249,7 @@ public function defaults(): array $defaults['allowChildren'] = false; } - return $defaults; + return Arr::undot($defaults); } /** @@ -1009,7 +1009,7 @@ protected function loadFiles(): void $this->files ??= (new FileCollection($files))->sort(); - $this->data = [...$this->defaults(), ...$this->data]; + $this->data = array_replace_recursive($this->defaults(), $this->data); } /**