Closed goldylucks closed 5 years ago
@goldylucks Thanks for the question, please have a look at the below code, even if you have disabled SSR, while building the App, the server.js is used and server hooks are used to create the static HTML thus below code help you achieve what you are looking for:
File:
import React from 'react';
// ... other imports
export default class Server {
apply(serverHandler) {
// ... other hooks or code
// Add google fonts
serverHandler.hooks.beforeHtmlRender.tapPromise('AddGoogleFonts', async (Application) => {
const { htmlProps: { head } } = Application;
head.push(<link key="google-roboto-fonts" href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" />);
});
}
Thanks @tirthbodawala , worked like a charm!
Couple of suggestions to avoid future questions:
server.js
is used even when SSR is offThoughts?
@goldylucks Good idea. Can absolutely do that.
Thanks a lot for the project!
I've disabled SSR and I want to add some
<link>
tags to the<head>
- ATM I need it for a google font for material ui, but I'm sure I'll need more modifications anyway.I've searched this repo and the
pawjs
repo and didn't find documentation or examples for that.I'm guessing it's ... done through the hooks? If so, where can I see info on that?
I'd be happy to submit a PR with docs with some guidance :)
Thanks again for the project! <3