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

refactor(www): Create PageMetadata component #21815

Merged
merged 48 commits into from
May 1, 2020
Merged

refactor(www): Create PageMetadata component #21815

merged 48 commits into from
May 1, 2020

Conversation

tesseralis
Copy link
Contributor

@tesseralis tesseralis commented Feb 28, 2020

Description

Create an abstraction over the raw <Helmet> component to consolidate common metadata.

TODO:

  • Test that everything makes sense and it actually works
  • Add more/standardize more descriptions and information
    • I'll make another issue for this

Motivation

  • Deduplicate common metadata used between Facebook, Twitter, and other crawlers.
  • Deduplicate text in metadata that needs to be translated.

Build

https://build-5fdd9a37-e2ae-4a55-a681-3bea24c30edb.gtsb.io/

Related Issues

fixes: #21562

Abstract over the raw <Helmet> component to consolidate common
descriptions.
@tesseralis tesseralis requested a review from a team as a code owner February 28, 2020 05:07
Copy link
Contributor Author

@tesseralis tesseralis left a comment

Choose a reason for hiding this comment

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

We can possibly change some stuff around and add in missing properties that should be here.

Another important omission is the og:img:alt tag:

og:image:alt - A description of what is in the image (not a caption). If the page specifies an og:image it should specify og:image:alt.

The blog pages have an imageTitle in their frontmatter but I'm not sure what's the proper tag for other docs. We can also table it for a different PR.

description={post.fields.excerpt}
image={post.frontmatter.image.childImageSharp.resize}
>
<meta property="og:url" content={href} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Fix #21563 in this PR and get rid of this.

<Helmet>
<title>{`${creator.name} - Creator`}</title>
</Helmet>
<PageMetadata title={`${creator.name} - Creator`} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could possibly add a description and image to this page if we'd like.

title={`${repoName}: Gatsby Starter`}
image={screenshot.childImageSharp.fluid}
description={`Gatsby Starters: ${repoName}`}
timeToRead={1}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are the hardcoded "timeToRead" labels in pages like this useful? We may as well get rid of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually... I'm trying to find information on reading time but I can't seem to find anything. Was this a feature that was taken out at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've found information on twitter:label1 only on third-party sites and it seems like it's been removed from the official twitter developer docs. Playing around with the validator doesn't show our time to read in any of our docs.

This comment was marked as off-topic.

Copy link
Contributor

Choose a reason for hiding this comment

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

twitter:label1 is used in e.g. Slack for richer preview

image

So for Slack twitter:label1 and twitter:label2 are valid and were added for this reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

As for your first question: I wouldn't say they are useful for starters and would switch the information for something like e.g. author or GitHub link.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well that's not intuitive at all. I'm adding a comment :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think switching the information is a good idea, but I'll leave that for a separate PR for now.

@tesseralis tesseralis requested a review from LekoArts March 2, 2020 19:28
@muescha
Copy link
Contributor

muescha commented Mar 3, 2020

twitter:image and twitter:description is not anymore in PageMetadata?

@tesseralis
Copy link
Contributor Author

@muescha According to the Twitter documentation:

When the Twitter card processor looks for tags on a page, it first checks for the Twitter-specific property, and if not present, falls back to the supported Open Graph property.

So we don't actually need these Twitter descriptions to generate a card (I think). You can verify this behavior by testing the build above with the Twitter card validator.

@muescha
Copy link
Contributor

muescha commented Mar 3, 2020

build-5fdd9a37-e2ae-4a55-a681-3bea24c30edb.gtsb.io

is this still the current build with all new commits?

@@ -20,7 +20,7 @@ export default function DefaultLayout({ location, locale, children }) {
return (
<LocaleContext.Provider value={locale || defaultLang}>
<Global styles={globalStyles} />
<SiteMetadata pathname={location.pathname} locale={locale} />
<SiteMetadata href={location.href} locale={locale} />
Copy link
Contributor

@muescha muescha Mar 3, 2020

Choose a reason for hiding this comment

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

when the link build-5fdd9a37-e2ae-4a55-a681-3bea24c30edb.gtsb.io is the current link to the build system,

then location.href is not available at SSR:

Check:

curl https://build-5fdd9a37-e2ae-4a55-a681-3bea24c30edb.gtsb.io/showcase/reactjs.org | grep "canonical" | less

results in:

<link data-react-helmet="true" rel="canonical"/>
<meta data-react-helmet="true" name="docsearch:version" content="2.0"/>
<meta data-react-helmet="true" name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,viewport-fit=cover"/>
<meta data-react-helmet="true" property="og:url"/>

while

curl https://www.gatsbyjs.org/showcase/reactjs.org | grep "canonical" | less
<link data-react-helmet="true" rel="canonical" href="https://www.gatsbyjs.org/showcase/reactjs.org"/>
<meta data-react-helmet="true" name="docsearch:version" content="2.0"/>
<meta data-react-helmet="true" name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,viewport-fit=cover"/>
<meta data-react-helmet="true" property="og:url" content="https://www.gatsbyjs.org"/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip! I'll change it back to using pathname. I didn't know that.

Copy link
Contributor

Choose a reason for hiding this comment

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

but check it before with a current build

i remember there was that problem, but unfortunly i can not find some issues or some docs (troubleshooting) about this ..

Copy link
Contributor

Choose a reason for hiding this comment

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

added issue:

  • docs: add info about location.href

thanks for the link to the blog post in code comments :)

# Conflicts:
#	www/src/templates/template-blog-post.js
@tesseralis tesseralis removed request for a team and LekoArts April 29, 2020 23:44
Copy link

@AishaBlake AishaBlake left a comment

Choose a reason for hiding this comment

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

There's so much going on in the head of these pages, I wasn't immediately sure that everything was where it needed to be but it's looking solid!

@AishaBlake
Copy link

Thanks for this (especially the tests), @tesseralis!

@AishaBlake AishaBlake merged commit 368da15 into master May 1, 2020
@delete-merged-branch delete-merged-branch bot deleted the page-metadata branch May 1, 2020 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(www): standardize common page metadata in <Helmet>
5 participants