From 9ddb382514342616ba4a6e14c41e7c065cca0dea Mon Sep 17 00:00:00 2001 From: Shigugu Date: Thu, 19 Dec 2024 12:15:32 +0100 Subject: [PATCH] fix: preview fails when page has missing author add optional chaining operators when accessing a page's author's name --- app/back-end/modules/render-html/contexts/page.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/back-end/modules/render-html/contexts/page.js b/app/back-end/modules/render-html/contexts/page.js index a6069868..03355d00 100644 --- a/app/back-end/modules/render-html/contexts/page.js +++ b/app/back-end/modules/render-html/contexts/page.js @@ -103,11 +103,11 @@ class RendererContextPage extends RendererContext { if (this.metaTitle === '') { this.metaTitle = this.siteConfig.advanced.pageMetaTitle.replace(/%pagetitle/g, this.page.title) .replace(/%sitename/g, siteName) - .replace(/%authorname/g, this.page.author.name); + .replace(/%authorname/g, this.page.author?.name); } else { this.metaTitle = this.metaTitle.replace(/%pagetitle/g, this.page.title) .replace(/%sitename/g, siteName) - .replace(/%authorname/g, this.page.author.name); + .replace(/%authorname/g, this.page.author?.name); } // If still meta title is empty - use page title @@ -117,7 +117,7 @@ class RendererContextPage extends RendererContext { this.metaDescription = this.metaDescription.replace(/%pagetitle/g, this.page.title) .replace(/%sitename/g, siteName) - .replace(/%authorname/g, this.page.author.name); + .replace(/%authorname/g, this.page.author?.name); this.context = { title: this.metaTitle,