Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blog] Add author and published_time meta tags #34382

Merged
merged 11 commits into from
Nov 2, 2022
41 changes: 20 additions & 21 deletions docs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@ export default function Home() {
<Head
title="MUI: The React component library you always wanted"
description="MUI provides a simple, customizable, and accessible library of React components. Follow your own design system, or start with Material Design."
/>
>
<script
type="application/ld+json"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: JSON.stringify({
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'MUI',
url: 'https://mui.com/',
logo: 'https://mui.com/static/logo.png',
sameAs: [
'https://twitter.com/MUI_hq',
'https://github.com/mui/',
'https://opencollective.com/mui',
],
}),
}}
/>
</Head>
<NoSsr>
<NewsletterToast />
</NoSsr>
Expand All @@ -40,26 +59,6 @@ export default function Home() {
<Divider />
</main>
<AppFooter />
<script
type="application/ld+json"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "MUI",
"url": "https://mui.com/",
"logo": "https://mui.com/static/logo.png",
"sameAs": [
"https://twitter.com/MUI_hq",
"https://github.com/mui/",
"https://opencollective.com/mui"
]
}
`,
}}
/>
</BrandingCssVarsProvider>
);
}
101 changes: 50 additions & 51 deletions docs/src/modules/components/TopLayoutBlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,56 @@ function TopLayoutBlog(props) {
disableAlternateLocale
card={card}
type="article"
/>
>
<meta name="author" content={headers.authors.map((key) => authors[key].name).join(', ')} />
<meta property="article:published_time" content={headers.date} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a battle between Facebook and Google with og standard vs schema.org. Since we do not know which service is using what, better to add them both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<script
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
type="application/ld+json"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: JSON.stringify({
'@context': 'https://schema.org',
'@type': 'Article',
publisher: {
'@type': 'Organization',
name: 'MUI blog',
url: 'https://mui.com/blog/',
logo: {
'@type': 'ImageObject',
url: 'https://mui.com/static/icons/512x512.png',
},
},
author: {
'@type': 'Person',
name: authors[headers.authors[0]].name,
image: {
'@type': 'ImageObject',
url: `${authors[headers.authors[0]].avatar}?s=${250}`,
width: 250,
height: 250,
},
sameAs: [`https://github.com/${authors[headers.authors[0]].github}`],
},
headline: finalTitle,
url: `https://mui.com${canonicalAsServer}`,
datePublished: headers.date,
dateModified: headers.date,
image: {
'@type': 'ImageObject',
url: card,
width: 1280,
height: 640,
},
keywords: headers.tags.join(', '),
description,
mainEntityOfPage: {
'@type': 'WebPage',
'@id': 'https://mui.com/blog/',
},
}),
}}
/>
</Head>
<Root className={className}>
<AppContainer component="main" className={classes.container}>
<Link
Expand Down Expand Up @@ -297,56 +346,6 @@ function TopLayoutBlog(props) {
<Divider />
<AppFooter />
</Root>
<script
type="application/ld+json"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `
{
"@context": "https://schema.org",
"@type": "Article",
"publisher": {
"@type": "Organization",
"name": "MUI blog",
"url": "https://mui.com/blog/",
"logo": {
"@type": "ImageObject",
"url": "https://mui.com/static/icons/512x512.png"
}
},
"author": {
"@type": "Person",
"name": "${authors[headers.authors[0]].name}",
"image": {
"@type": "ImageObject",
"url": "${authors[headers.authors[0]].avatar}?s=${250}",
"width": 250,
"height": 250
},
"sameAs": [
"https://github.com/${authors[headers.authors[0]].github}"
]
},
"headline": "${finalTitle}",
"url": "https://mui.com${canonicalAsServer}",
"datePublished": "${headers.date}",
"dateModified": "${headers.date}",
"image": {
"@type": "ImageObject",
"url": "${card}",
"width": 1280,
"height": 640
},
"keywords": "${headers.tags.join(', ')}",
"description": "${description}",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://mui.com/blog/"
}
}
`,
}}
/>
</BrandingProvider>
);
}
Expand Down