-
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(gatsby-core-utils): Add node.js export, and move site-metadata into its own function #26237
Conversation
Gatsby Cloud Build Reportclient-only-paths 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 18s PerformanceLighthouse report
|
Gatsby Cloud Build Reportusing-styled-components 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 11s PerformanceLighthouse report
|
Gatsby Cloud Build Reportusing-reach-skip-nav 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 20s PerformanceLighthouse report
|
Gatsby Cloud Build Reportgatsby-master 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 16m PerformanceLighthouse report
|
87ea536
to
29cdd16
Compare
Gatsby Cloud Build Reportgatsby 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 20m |
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.
lgtm
|
||
export async function updateSiteMetadata( | ||
metadata: ISiteMetadata, | ||
merge = true |
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.
Nit
I would kind of suggest to not use a default and to use constants to prevent magic variables and "the boolean trap"-problem.
export const AND_MERGE = true
export const NOT_MERGE = false
or smth, or to export a version of this function that passes on false for you
export async function updateSiteMetadataAndMerge(
metadata: ISiteMetadata
) {
return updateSiteMetadata(metadata, true)
}
etc
const oldMetadata = (await getSiteMetadata(metadata.sitePath)) || {} | ||
metadata = { ...oldMetadata, ...metadata } |
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.
Nit
const oldMetadata = (await getSiteMetadata(metadata.sitePath)) || {} | |
metadata = { ...oldMetadata, ...metadata } | |
const oldMetadata = await getSiteMetadata(metadata.sitePath) | |
if (oldMetadata) { | |
metadata = { ...oldMetadata, ...metadata } | |
} |
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 is much nicer than /dist/service-lock
! LGTM 👍
Gatsby Cloud Build Reportgatsby 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 3h PerformanceLighthouse report
|
ca47529
to
fd8c610
Compare
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.
Nice! Great teamwork here.
This adds an export for node.js-specific functions. It also adds new
updateSIteMetadata
andgetSiteMetadata
, which use service-lock.