Skip to content

Commit

Permalink
Merge pull request #6 from eAdded/HeadSSR
Browse files Browse the repository at this point in the history
Head ssr
  • Loading branch information
aniketfuryrocks authored Aug 3, 2020
2 parents d1f73b0 + 23e9e72 commit f31cd70
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firejsx",
"main": "FireJSX.js",
"version": "0.9.4",
"version": "0.9.5",
"license": "GPL-3.0-or-later",
"description": "The React Framework for SSB, SSR and Serverless technologies",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/GlobalsSetter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
global.FireJSX = {
version: "0.9.4"
version: "0.9.5"
}
5 changes: 2 additions & 3 deletions src/architects/StaticArchitect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {join} from "path"
import Page from "../classes/Page";
import {Helmet} from "react-helmet"

export interface StaticConfig {
lib: string,
Expand Down Expand Up @@ -81,9 +80,9 @@ export default class {
) : ""
//helmet
if (this.config.ssr) {
const helmet = Helmet.renderStatic();
const helmet = global.__FIREJSX_HELMET__.renderStatic();
for (let helmetKey in helmet)
head += helmet[helmetKey].toString()
head = helmet[helmetKey].toString() + head
}
//concat every thing
return "<!doctype html>" +
Expand Down
4 changes: 2 additions & 2 deletions src/architects/WebpackArchitect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default class {
publicPath: `${this.$.prefix}/${this.$.lib}/`,
path: `${this.$.outDir}/${this.$.lib}/`,
//hot
hotUpdateMainFilename: 'hot/[hash].hot.json',
hotUpdateChunkFilename: 'hot/[hash].hot.js'
hotUpdateMainFilename: `${this.$.lib}/[hash].hot.json`,
hotUpdateChunkFilename: `${this.$.lib}/[hash].hot.js`
},
externals: {
react: "React",
Expand Down
3 changes: 1 addition & 2 deletions src/components/Head.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import {Helmet} from "react-helmet"
export default Helmet
export default window.__FIREJSX_HELMET__
8 changes: 8 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ declare module NodeJS {
React?: any,
ReactDOM?: any,
ReactDOMServer?: any,
__FIREJSX_HELMET__: {
renderStatic: () => {
[Key: string]: {
toString: () => string
}
},
canUseDOM: boolean
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/web/externalGroupFull.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
global.React = require("react");
global.ReactDOM = require("react-dom")
global.ReactDOMServer = require("react-dom/server")
global.ReactDOMServer = require("react-dom/server")
global.__FIREJSX_HELMET__ = require("react-helmet").Helmet
global.__FIREJSX_HELMET__.canUseDOM = false
1 change: 1 addition & 0 deletions src/web/externalGroupSemi.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window.React = require("react");
window.ReactDOM = require("react-dom")
window.__FIREJSX_HELMET__ = require("react-helmet").Helmet
require("./LinkApi.js")
1 change: 1 addition & 0 deletions test/src/pages/about/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Wrap(() => {
<div>
<Head>
<title>About</title>
<meta name={"asd"}/>
</Head>
<Loader effect={React.useEffect}>
<LoadingBar/>
Expand Down

0 comments on commit f31cd70

Please sign in to comment.