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

feat: add generator meta tag for gatsby version #8221

Merged
merged 10 commits into from
Sep 17, 2018

Conversation

DSchau
Copy link
Contributor

@DSchau DSchau commented Sep 17, 2018

Simple PR that adds a meta generator tag utilizing the current version of gatsby specified in node_modules/gatsby/package.json.

This will be useful for analytics, seeing what % of Gatsby sites have migrated (since this won't be in Gatsby v1 sites), etc. etc.

@@ -8,6 +8,7 @@ const { get, merge, isObject, flatten, uniqBy } = require(`lodash`)
const apiRunner = require(`./api-runner-ssr`)
const syncRequires = require(`./sync-requires`)
const { dataPaths, pages } = require(`./data.json`)
const { version: gatsbyVersion } = require(join(process.cwd(), 'node_modules/gatsby/package.json'))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can just do require(`gatsby/package.json`)?

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 sure can! Thank you :)

@DSchau DSchau changed the title WIP: feat: add generator meta tag for gatsby version feat: add generator meta tag for gatsby version Sep 17, 2018
@@ -12,6 +12,7 @@ export default class HTML extends React.Component {
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
{this.props.gatsbyVersion && <meta name="generator" content={`Gatsby ${this.props.gatsbyVersion}`} />}
{this.props.headComponents}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding it to the default html component (which is often overrided), set it as a component in headComponents

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 was so close to doing it this way instead 🙃 Will do it that way, one sec

@pieh
Copy link
Contributor

pieh commented Sep 17, 2018

Also could we use something like this:

headComponents.push(
<link
rel="preload"
key={dataPath}
href={dataPath}
as="fetch"
crossOrigin="use-credentials"
/>
)

so people with custom html.js don't miss out on this head element? :) (we can get away with extra props)

@@ -50,7 +51,9 @@ const createElement = React.createElement

export default (pagePath, callback) => {
let bodyHtml = ``
let headComponents = []
let headComponents = [
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 this is OK?

This ends up putting it after some things like style elements and stuff in the head tags, which is probably fine.

i.e.

<style>
/* snipped */
</style>
<meta name="generator" content="Gatsby 2.0.0-rc.26"/>
<title data-react-helmet="true">Reproduction of #7590</title>
<meta data-react-helmet="true" name="description" content="Sample"/>
<meta data-react-helmet="true" name="keywords" content="sample, something"/>
<style type="text/css"></style>

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, the order doesn't matter

@@ -32,6 +32,7 @@ HTML.propTypes = {
htmlAttributes: PropTypes.object,
headComponents: PropTypes.array,
bodyAttributes: PropTypes.object,
gatsbyVersion: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs removed

Copy link
Contributor Author

@DSchau DSchau Sep 17, 2018

Choose a reason for hiding this comment

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

Thanks! (and done)

Copy link
Contributor

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

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

🎉

@KyleAMathews KyleAMathews merged commit 0de459a into gatsbyjs:master Sep 17, 2018
@DSchau DSchau deleted the gatsby/generator-version branch September 17, 2018 18:29
yamgent pushed a commit to MarkBind/markbind that referenced this pull request Mar 14, 2019
The Agolia team has requested that we add <meta name="generator">
(#754) tags to identify pages generated by MarkBind. Since this tag is
part of HTML5 [1] and can be used by other external providers to
identify MarkBind generated sites, we can include this tag in all
MarkBind pages. We can also include the version number to allow
tracking the use of different MarkBind versions, as other projects
have done [2, 3].

Let's include the <meta name="generator"> tag to identify MarkBind
pages, as well as including the version number to track the use of
different MarkBind versions.

[1]: https://www.w3.org/TR/html5/document-metadata.html#generator
[2]: hexojs/site#649
[3]: gatsbyjs/gatsby#8221
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.

3 participants