mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-21 20:17:50 +02:00
fix: author/image adjustments in BlogPosting schema (#5346)
This commit is contained in:
parent
3fc47938a5
commit
cbff487516
1 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue