Skip to content

Commit

Permalink
fix: author/image adjustments in BlogPosting schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Aug 11, 2021
1 parent 1f8fa5e commit 0de9a31
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

import React from 'react';
import Head from '@docusaurus/Head';
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
import type {Props} from '@theme/BlogPostStructuredData';

function BlogPostStructuredData(props: Props): JSX.Element {
const {withBaseUrl} = useBaseUrlUtils();
const {frontMatter, frontMatterAssets, metadata} = props;
const {date, title, description} = metadata;

const image = frontMatterAssets.image ?? frontMatter.image;

const {author} = frontMatter;
const authorURL = frontMatter.author_url || frontMatter.authorURL;
const authorTitle = frontMatter.author_title || frontMatter.authorTitle;

// details on structured data support: https://developers.google.com/search/docs/data-types/article#non-amp
// and https://schema.org/BlogPosting
Expand All @@ -25,11 +26,11 @@ function BlogPostStructuredData(props: Props): JSX.Element {
'@type': 'BlogPosting',
headline: title,
description,
...(image ? {image: [image]} : {}),
...(image ? {image: [withBaseUrl(image, {absolute: true})]} : {}),
datePublished: date,
author: {
'@type': 'Person',
name: authorTitle,
...(author ? {name: author} : {}),
url: authorURL,
},
};
Expand Down

0 comments on commit 0de9a31

Please sign in to comment.