-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat: add generator meta tag for gatsby version #8221
Conversation
@@ -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')) |
There was a problem hiding this comment.
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`)
?
There was a problem hiding this comment.
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 :)
@@ -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} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Also could we use something like this: gatsby/packages/gatsby/cache-dir/static-entry.js Lines 274 to 282 in cf7fd8a
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 = [ |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! (and done)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
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
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.