Created
November 11, 2022 21:42
-
-
Save jacobrask/57535220a474917eaaff9e7da38a1733 to your computer and use it in GitHub Desktop.
Enhance in Next.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enhance from "@enhance/ssr"; | |
import postProcess from "next/dist/server/post-process.js"; | |
import MyButton from "./src/elements/my-button.mjs"; | |
import MyIcon from "./src/elements/my-icon.mjs"; | |
import styleTransform from "@enhance/enhance-style-transform"; | |
const _postProcessHTML = postProcess.postProcessHTML; | |
postProcess.postProcessHTML = async function postProcessHTML( | |
pathname, | |
content, | |
...rest | |
) { | |
const html = enhance({ | |
elements: { | |
"my-button": MyButton, | |
"my-icon": MyIcon, | |
}, | |
styleTransforms: [styleTransform], | |
}); | |
return _postProcessHTML(pathname, html`${content}`, ...rest); | |
}; | |
export default {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment