Skip to content

Commit

Permalink
fix(maleo-core/server): unique header and head
Browse files Browse the repository at this point in the history
give unique header and head for server
  • Loading branch information
Alvin Kristanto committed Jul 30, 2019
1 parent cd5ce2f commit e27c3c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/Maleo.js/src/head/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const METATYPES = ['name', 'httpEquiv', 'charSet', 'itemProp'];
which shouldn't be duplicated, like <title/>
Also adds support for deduplicated `key` properties
*/
function unique() {
export function unique() {
const keys = new Set();
const tags = new Set();
const metaTypes = new Set();
Expand Down
10 changes: 4 additions & 6 deletions packages/Maleo.js/src/render/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { stringify } from 'flatted';

import { HeaderProps, DocumentProps, DocumentContext } from '@interfaces/render';
import { SERVER_INITIAL_DATA, DIV_MALEO_ID } from '@constants/index';
import { unique } from '@head/head';

// Extendable document
export default class Document extends React.Component<DocumentProps, {}> {
Expand Down Expand Up @@ -60,14 +61,11 @@ export class Header extends React.Component<HeaderProps, {}> {
const { head } = this.context;
const { children } = this.props;

const uniqueHead = [...head, ...React.Children.toArray(children)].filter(unique());

return (
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1.0" />
<meta httpEquiv="X-UA-Compatible" content="ie=edge" />

{children}
{head}
{uniqueHead}

{this.preloadScripts()}
</head>
Expand Down

0 comments on commit e27c3c1

Please sign in to comment.