diff --git a/cigaradvisor/blocks/article-teaser/article-teaser.js b/cigaradvisor/blocks/article-teaser/article-teaser.js index dc5100a..f06e7b5 100644 --- a/cigaradvisor/blocks/article-teaser/article-teaser.js +++ b/cigaradvisor/blocks/article-teaser/article-teaser.js @@ -5,6 +5,7 @@ import { // eslint-disable-next-line max-len export function buildArticleTeaser(parentElement, article) { + const author = article.author || {}; const ldjson = { '@context': 'http://schema.org', '@type': 'BlogPosting', @@ -23,8 +24,8 @@ export function buildArticleTeaser(parentElement, article) { dateModified: new Date(article.lastModified * 1000).toISOString(), author: { '@type': 'Person', - name: article.author.name, - url: `https://www.famous-smoke.com${article.author.path}`, + name: author.name || 'Unknown', + url: `https://www.famous-smoke.com${author.path || '/author'}`, }, image: `https://www.famous-smoke.com${article.image}`, }; @@ -47,7 +48,7 @@ export function buildArticleTeaser(parentElement, article) { ${article.heading}
- By ${(article.author && article.author.name) ? article.author.name : ''} + By ${author.name || 'Unknown'}
diff --git a/cigaradvisor/blocks/articleheader/articleheader.js b/cigaradvisor/blocks/articleheader/articleheader.js index e584b4b..910dfe2 100644 --- a/cigaradvisor/blocks/articleheader/articleheader.js +++ b/cigaradvisor/blocks/articleheader/articleheader.js @@ -10,7 +10,7 @@ export default async function decorate(block) { const picture = block.querySelector('picture'); const category = await fetchCategoryInfo(config.category); - const author = await fetchAuthorInfo(config.author); + const author = await fetchAuthorInfo(config.author) || {}; const sect = section( {}, div({ class: 'image-wrapper' }, picture), @@ -18,7 +18,7 @@ export default async function decorate(block) { { class: 'article-info' }, div({ class: 'article-category' }, a({ href: config.category }, category.heading)), h1(config.heading), - div({ class: 'article-author' }, a({ href: config.author }, author.name)), + div({ class: 'article-author' }, a({ href: config.author }, author.name || 'Unknown')), ), ); block.replaceChildren(sect);