Replies: 2 comments 8 replies
-
Do you mean |
Beta Was this translation helpful? Give feedback.
-
@muuvmuuv create node field with hash (for useStaticQuery later)const { createHash } = require("crypto")
exports.onCreateNode = ({node, actions}) => {
if(node?.frontmatter?.mailto) {
const hash = createHash("sha256")
hash.update(node.frontmatter.mailto)
const digest = hash.digest().toString("hex")
actions.createNodeField({
name: "mailtoHash",
node,
value: digest
})
}
} wrapper component for "static interception"import React from 'react'
import { graphql } from 'gatsby'
const MailSSRIntercepted = ({ mailto, ...props }) => {
const data = useStaticQuery(graphql`
mdx(...) {
fields {
mailtoHash
}
frontmatter {
mailto
}
}
`)
return <Mail mailto={typeof window === 'undefined' ? `${data.mdx.frontmatter.mailto}${data.mdx.fields.mailtoHash}` : mailto} {...props } />
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to pre-render/change a prop I pass to a component before it is delivered to the browser. With
getServerSideProp
I could do something like that I think. Does Gatsby have any API/Function to change properties passed to a component on build-time/SSR?Something like:
Beta Was this translation helpful? Give feedback.
All reactions