Skip to content

Commit f4d3162

Browse files
committed
Website: fix html meta rendering
1 parent 4a97c83 commit f4d3162

6 files changed

Lines changed: 143 additions & 89 deletions

File tree

‎website/bsconfig.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"reason-future",
2525
"reason-react",
2626
"react-from-svg",
27-
"../bs-react-native-next"
27+
"../bs-react-native-next",
28+
"@moox/bs-react-helmet"
2829
]
2930
}

‎website/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"test": "yarn svg && yarn re:build"
2222
},
2323
"devDependencies": {
24+
"@moox/bs-react-helmet": "^2.0.0",
2425
"bs-platform": "^5.0.1",
2526
"cpy-cli": "^2.0.0",
2627
"front-matter": "^3.0.1",
@@ -32,6 +33,7 @@
3233
"react": "^16.8.0",
3334
"react-dom": "^16.8.0",
3435
"react-from-svg": "^0.1.3",
36+
"react-helmet": "^5.2.0",
3537
"react-native-web": "^0.11.2",
3638
"reason-future": "^2.4.0",
3739
"reason-highlightjs": "^0.2.0",

‎website/scripts/Prerender.re‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ let make = (~url: string, ~pageData) => {
2626
);
2727
let html = renderToString(app##element);
2828
let css = renderToStaticMarkup(app##getStyleElement());
29+
let helmet = BsReactHelmet.renderStatic();
30+
let helmetMeta = helmet##meta##toString();
31+
let helmetLinks = helmet##link##toString();
32+
let helmetTitle = helmet##title##toString();
33+
let helmetStyle = helmet##style##toString();
34+
let helmetScript = helmet##script##toString();
2935
{j|
3036
<!DOCTYPE html>
3137
<html style="height:100%">
32-
<meta charset="utf-8">
33-
<meta name="viewport" content="width=device-width, initial-scale=1">
34-
$css
35-
<body style="min-height:100%">
36-
$html
37-
</body>
38+
<head>$helmetMeta $helmetLinks $helmetTitle $helmetStyle $helmetScript $css</head>
39+
<body style="min-height:100%">$html</body>
3840
</html>|j};
3941
};
4042

‎website/src/components/App.re‎

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,96 +7,22 @@ open ReactNative;
77
let make =
88
(~pageData: option(PageContent.pageData)=?, ~currentLocation: location) => {
99
switch (Js.String.split("/", currentLocation##pathname)->List.fromArray) {
10-
| [""] => <> <HeaderLarge currentLocation /> <Homepage /> </>
10+
| [""] => <> <Head /> <HeaderLarge currentLocation /> <Homepage /> </>
1111
| _ =>
1212
<>
13-
<link
14-
rel="apple-touch-icon"
15-
sizes="180x180"
16-
href="/bs-react-native/apple-touch-icon.png"
17-
/>
18-
<link
19-
rel="icon"
20-
type_="image/png"
21-
sizes="32x32"
22-
href="/bs-react-native/favicon-32x32.png"
23-
/>
24-
<link
25-
rel="icon"
26-
type_="image/png"
27-
sizes="16x16"
28-
href="/bs-react-native/favicon-16x16.png"
29-
/>
30-
<link rel="manifest" href="/bs-react-native/site.webmanifest" />
31-
{ReactDOMRe.createElementVariadic(
32-
"link",
33-
~props=
34-
ReactDOMRe.objToDOMProps({
35-
"rel": "mask-icon",
36-
"href": "/bs-react-native/safari-pinned-tab.svg",
37-
"color": "#222222",
38-
}),
39-
[||],
40-
)}
41-
<link rel="shortcut icon" href="/bs-react-native/favicon.ico" />
42-
<meta name="msapplication-TileColor" content="#222222" />
43-
<meta
44-
name="msapplication-config"
45-
content="/bs-react-native/browserconfig.xml"
46-
/>
47-
<meta name="theme-color" content="#222222" />
48-
<link
49-
rel="stylesheet"
50-
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.min.css"
51-
/>
52-
<style
53-
dangerouslySetInnerHTML={
54-
"__html": {|
55-
.hljs {
56-
font-size: 14px;
57-
padding: 20px;
58-
border: 1px solid rgba(0,0,0,0.05);
59-
background: rgba(0,0,0,0.01);
60-
border-radius: 4px;
61-
}
62-
63-
.hljs.javascript {
64-
background-color: rgba(247, 223, 30, .03)
65-
}
66-
67-
table .hljs {
68-
border: none;
69-
background: none
70-
}
71-
72-
.hljs-operator {
73-
color: #a626a4
74-
}
75-
76-
.hljs-character {
77-
color: #50a14f
78-
}
79-
80-
.hljs-module-identifier {
81-
color: #4078f2
82-
}
83-
84-
.hljs-constructor {
85-
color: #e45649
86-
}
87-
88-
.stick { position: -webkit-sticky; position: sticky; }
89-
90-
|},
91-
}
92-
/>
13+
<Head />
9314
<HeaderLarge currentLocation />
9415
{pageData
9516
->Option.map(pageData =>
9617
<Container
9718
style=Style.(
9819
style(~flexDirection=`row, ~height=100.->Size.pct, ())
9920
)>
21+
<BsReactHelmet>
22+
<title>
23+
{("BsReactNative " ++ pageData.title)->React.string}
24+
</title>
25+
</BsReactHelmet>
10026
<Sidebar modulesIndex={pageData.modulesIndex} />
10127
<PageContent pageData />
10228
</Container>

‎website/src/components/Head.re‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
[@react.component]
2+
let make = () =>
3+
<BsReactHelmet>
4+
<meta charSet="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<link
7+
rel="apple-touch-icon"
8+
sizes="180x180"
9+
href="/bs-react-native/apple-touch-icon.png"
10+
/>
11+
<link
12+
rel="icon"
13+
type_="image/png"
14+
sizes="32x32"
15+
href="/bs-react-native/favicon-32x32.png"
16+
/>
17+
<link
18+
rel="icon"
19+
type_="image/png"
20+
sizes="16x16"
21+
href="/bs-react-native/favicon-16x16.png"
22+
/>
23+
<link rel="manifest" href="/bs-react-native/site.webmanifest" />
24+
{ReactDOMRe.createElementVariadic(
25+
"link",
26+
~props=
27+
ReactDOMRe.objToDOMProps({
28+
"rel": "mask-icon",
29+
"href": "/bs-react-native/safari-pinned-tab.svg",
30+
"color": "#222222",
31+
}),
32+
[||],
33+
)}
34+
<link rel="shortcut icon" href="/bs-react-native/favicon.ico" />
35+
<meta name="msapplication-TileColor" content="#222222" />
36+
<meta
37+
name="msapplication-config"
38+
content="/bs-react-native/browserconfig.xml"
39+
/>
40+
<meta name="theme-color" content="#222222" />
41+
<link
42+
rel="stylesheet"
43+
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.min.css"
44+
/>
45+
<style>
46+
{|
47+
.hljs {
48+
font-size: 14px;
49+
padding: 20px;
50+
border: 1px solid rgba(0,0,0,0.05);
51+
background: rgba(0,0,0,0.01);
52+
border-radius: 4px;
53+
}
54+
55+
.hljs.javascript {
56+
background-color: rgba(247, 223, 30, .03)
57+
}
58+
59+
table .hljs {
60+
border: none;
61+
background: none
62+
}
63+
64+
.hljs-operator {
65+
color: #a626a4
66+
}
67+
68+
.hljs-character {
69+
color: #50a14f
70+
}
71+
72+
.hljs-module-identifier {
73+
color: #4078f2
74+
}
75+
76+
.hljs-constructor {
77+
color: #e45649
78+
}
79+
80+
.stick { position: -webkit-sticky; position: sticky; }
81+
82+
|}
83+
->React.string
84+
</style>
85+
</BsReactHelmet>;

‎yarn.lock‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,11 @@
11321132
npmlog "^4.1.2"
11331133
write-file-atomic "^2.3.0"
11341134

1135+
"@moox/bs-react-helmet@^2.0.0":
1136+
version "2.0.0"
1137+
resolved "https://registry.yarnpkg.com/@moox/bs-react-helmet/-/bs-react-helmet-2.0.0.tgz#d1bca09ff1d2c31d0a76a93a0660ef81cb74353d"
1138+
integrity sha512-2Pjd46s8VR8E9xWztCw7t2JoM9A7y7wm4kwybU7SYHDJY1INQtyvpQUbpBcbBe5Vpq0UOM4UnQFkuAzkWNb+WQ==
1139+
11351140
"@mrmlnc/readdir-enhanced@^2.2.1":
11361141
version "2.2.1"
11371142
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
@@ -3276,6 +3281,11 @@ deep-assign@^3.0.0:
32763281
dependencies:
32773282
is-obj "^1.0.0"
32783283

3284+
deep-equal@^1.0.1:
3285+
version "1.0.1"
3286+
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
3287+
integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=
3288+
32793289
deep-extend@^0.6.0:
32803290
version "0.6.0"
32813291
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
@@ -3686,6 +3696,11 @@ execa@^1.0.0:
36863696
signal-exit "^3.0.0"
36873697
strip-eof "^1.0.0"
36883698

3699+
exenv@^1.2.1:
3700+
version "1.2.2"
3701+
resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d"
3702+
integrity sha1-KueOhdmJQVhnCwPUe+wfA72Ru50=
3703+
36893704
expand-brackets@^0.1.4:
36903705
version "0.1.5"
36913706
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b"
@@ -7570,7 +7585,7 @@ promzard@^0.3.0:
75707585
dependencies:
75717586
read "1"
75727587

7573-
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
7588+
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2:
75747589
version "15.7.2"
75757590
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
75767591
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -7764,6 +7779,16 @@ react-from-svg@^0.1.3:
77647779
reason-future "^2.4.0"
77657780
reason-react "^0.7.0"
77667781

7782+
react-helmet@^5.2.0:
7783+
version "5.2.0"
7784+
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7"
7785+
integrity sha1-qBgR3yExOm1VxfBYxK66XW89l6c=
7786+
dependencies:
7787+
deep-equal "^1.0.1"
7788+
object-assign "^4.1.1"
7789+
prop-types "^15.5.4"
7790+
react-side-effect "^1.1.0"
7791+
77677792
react-is@^16.8.1:
77687793
version "16.8.4"
77697794
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2"
@@ -7913,6 +7938,14 @@ react-proxy@^1.1.7:
79137938
lodash "^4.6.1"
79147939
react-deep-force-update "^1.0.0"
79157940

7941+
react-side-effect@^1.1.0:
7942+
version "1.1.5"
7943+
resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-1.1.5.tgz#f26059e50ed9c626d91d661b9f3c8bb38cd0ff2d"
7944+
integrity sha512-Z2ZJE4p/jIfvUpiUMRydEVpQRf2f8GMHczT6qLcARmX7QRb28JDBTpnM2g/i5y/p7ZDEXYGHWg0RbhikE+hJRw==
7945+
dependencies:
7946+
exenv "^1.2.1"
7947+
shallowequal "^1.0.1"
7948+
79167949
react-timer-mixin@^0.13.2, react-timer-mixin@^0.13.4:
79177950
version "0.13.4"
79187951
resolved "https://registry.yarnpkg.com/react-timer-mixin/-/react-timer-mixin-0.13.4.tgz#75a00c3c94c13abe29b43d63b4c65a88fc8264d3"
@@ -8538,6 +8571,11 @@ setprototypeof@1.1.0:
85388571
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656"
85398572
integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==
85408573

8574+
shallowequal@^1.0.1:
8575+
version "1.1.0"
8576+
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
8577+
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
8578+
85418579
shebang-command@^1.2.0:
85428580
version "1.2.0"
85438581
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"

0 commit comments

Comments
 (0)