mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-22 20:47:53 +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 React from 'react';
|
||||||
import Head from '@docusaurus/Head';
|
import Head from '@docusaurus/Head';
|
||||||
|
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
||||||
import type {Props} from '@theme/BlogPostStructuredData';
|
import type {Props} from '@theme/BlogPostStructuredData';
|
||||||
|
|
||||||
function BlogPostStructuredData(props: Props): JSX.Element {
|
function BlogPostStructuredData(props: Props): JSX.Element {
|
||||||
|
const {withBaseUrl} = useBaseUrlUtils();
|
||||||
const {frontMatter, frontMatterAssets, metadata} = props;
|
const {frontMatter, frontMatterAssets, metadata} = props;
|
||||||
const {date, title, description} = metadata;
|
const {date, title, description} = metadata;
|
||||||
|
|
||||||
const image = frontMatterAssets.image ?? frontMatter.image;
|
const image = frontMatterAssets.image ?? frontMatter.image;
|
||||||
|
const {author} = frontMatter;
|
||||||
const authorURL = frontMatter.author_url || frontMatter.authorURL;
|
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
|
// details on structured data support: https://developers.google.com/search/docs/data-types/article#non-amp
|
||||||
// and https://schema.org/BlogPosting
|
// and https://schema.org/BlogPosting
|
||||||
|
@ -25,11 +26,11 @@ function BlogPostStructuredData(props: Props): JSX.Element {
|
||||||
'@type': 'BlogPosting',
|
'@type': 'BlogPosting',
|
||||||
headline: title,
|
headline: title,
|
||||||
description,
|
description,
|
||||||
...(image ? {image: [image]} : {}),
|
...(image ? {image: [withBaseUrl(image, {absolute: true})]} : {}),
|
||||||
datePublished: date,
|
datePublished: date,
|
||||||
author: {
|
author: {
|
||||||
'@type': 'Person',
|
'@type': 'Person',
|
||||||
name: authorTitle,
|
...(author ? {name: author} : {}),
|
||||||
url: authorURL,
|
url: authorURL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue