Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion formwork/src/Pages/ContentFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Formwork\Files\File;
use Formwork\Parsers\Yaml;
use Formwork\Utils\Arr;
use Formwork\Utils\FileSystem;
use UnexpectedValueException;

Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions formwork/src/Pages/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -249,7 +249,7 @@ public function defaults(): array
$defaults['allowChildren'] = false;
}

return $defaults;
return Arr::undot($defaults);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down