diff --git a/src/Structures/Page.php b/src/Structures/Page.php index 4d0b6b7aaf4..f123d76c081 100644 --- a/src/Structures/Page.php +++ b/src/Structures/Page.php @@ -39,6 +39,8 @@ class Page implements Arrayable, ArrayAccess, Augmentable, Entry, JsonSerializab protected $title; protected $depth; protected $data = []; + private $absoluteUrl; + private $absoluteUrlWithoutRedirect; private $blueprint; public function __construct() @@ -211,20 +213,28 @@ public function uri() public function absoluteUrl() { + if ($this->absoluteUrl !== null) { + return $this->absoluteUrl; + } + if ($this->url) { - return URL::makeAbsolute($this->url); + return $this->absoluteUrl = URL::makeAbsolute($this->url); } - return optional($this->entry())->absoluteUrl(); + return $this->absoluteUrl = optional($this->entry())->absoluteUrl(); } public function absoluteUrlWithoutRedirect() { + if ($this->absoluteUrlWithoutRedirect !== null) { + return $this->absoluteUrlWithoutRedirect; + } + if ($this->url) { - return $this->absoluteUrl(); + return $this->absoluteUrlWithoutRedirect = $this->absoluteUrl(); } - return optional($this->entry())->absoluteUrlWithoutRedirect(); + return $this->absoluteUrlWithoutRedirect = optional($this->entry())->absoluteUrlWithoutRedirect(); } public function isRoot()