mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merge pull request #1376 from xavcz/meta-helmet
Meta SSR with react-helmet
This commit is contained in:
commit
b8f2915504
4 changed files with 11 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
||||||
"react-bootstrap-datetimepicker": "0.0.22",
|
"react-bootstrap-datetimepicker": "0.0.22",
|
||||||
"react-cookie": "^0.4.6",
|
"react-cookie": "^0.4.6",
|
||||||
"react-dom": "^15.0.0",
|
"react-dom": "^15.0.0",
|
||||||
|
"react-helmet": "^3.1.0",
|
||||||
"react-intl": "^2.1.3",
|
"react-intl": "^2.1.3",
|
||||||
"react-komposer": "^1.8.0",
|
"react-komposer": "^1.8.0",
|
||||||
"react-mounter": "^1.2.0",
|
"react-mounter": "^1.2.0",
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import React, { PropTypes, Component } from 'react';
|
import React, { PropTypes, Component } from 'react';
|
||||||
import { DocHead } from 'meteor/kadira:dochead';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
class HeadTags extends Component {
|
class HeadTags extends Component {
|
||||||
render() {
|
render() {
|
||||||
DocHead.removeDocHeadAddedTags();
|
|
||||||
|
|
||||||
const url = !!this.props.url ? this.props.url : Telescope.utils.getSiteUrl();
|
const url = !!this.props.url ? this.props.url : Telescope.utils.getSiteUrl();
|
||||||
const title = !!this.props.title ? this.props.title : Telescope.settings.get("title", "Nova");
|
const title = !!this.props.title ? this.props.title : Telescope.settings.get("title", "Nova");
|
||||||
|
@ -22,7 +21,7 @@ class HeadTags extends Component {
|
||||||
image = Telescope.utils.getSiteUrl() + image;
|
image = Telescope.utils.getSiteUrl() + image;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metas = [
|
const meta = [
|
||||||
{ charset: "utf-8" },
|
{ charset: "utf-8" },
|
||||||
{ name: "description", content: description },
|
{ name: "description", content: description },
|
||||||
// responsive
|
// responsive
|
||||||
|
@ -40,16 +39,14 @@ class HeadTags extends Component {
|
||||||
{ name: "twitter:description", content: description }
|
{ name: "twitter:description", content: description }
|
||||||
];
|
];
|
||||||
|
|
||||||
const links = [
|
const link = [
|
||||||
{ rel: "canonical", href: Telescope.utils.getSiteUrl() },
|
{ rel: "canonical", href: Telescope.utils.getSiteUrl() },
|
||||||
{ rel: "shortcut icon", href: Telescope.settings.get("favicon", "/img/favicon.ico") }
|
{ rel: "shortcut icon", href: Telescope.settings.get("favicon", "/img/favicon.ico") }
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{ DocHead.setTitle(title) }
|
<Helmet title={title} meta={meta} link={link} />
|
||||||
{ metas.map(meta => DocHead.addMeta(meta)) }
|
|
||||||
{ links.map(link => DocHead.addLink(link)) }
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ Package.onUse(function (api) {
|
||||||
'tmeasday:check-npm-versions@0.3.1',
|
'tmeasday:check-npm-versions@0.3.1',
|
||||||
'std:accounts-ui@1.2.6',
|
'std:accounts-ui@1.2.6',
|
||||||
'utilities:react-list-container@0.1.10',
|
'utilities:react-list-container@0.1.10',
|
||||||
'kadira:dochead@1.5.0'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
api.mainModule("lib/server.js", "server");
|
api.mainModule("lib/server.js", "server");
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { ListContainer, DocumentContainer } from "meteor/utilities:react-list-co
|
||||||
// import useNamedRoutes from 'use-named-routes';
|
// import useNamedRoutes from 'use-named-routes';
|
||||||
import createBrowserHistory from 'history/lib/createBrowserHistory';
|
import createBrowserHistory from 'history/lib/createBrowserHistory';
|
||||||
import Events from "meteor/nova:events";
|
import Events from "meteor/nova:events";
|
||||||
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
// // ------------------------------------- Other -------------------------------- //
|
// // ------------------------------------- Other -------------------------------- //
|
||||||
|
|
||||||
|
@ -48,6 +49,11 @@ Meteor.startup(() => {
|
||||||
|
|
||||||
clientOptions.props = {onUpdate: () => {Events.analyticsRequest(); Messages.clearSeen();}};
|
clientOptions.props = {onUpdate: () => {Events.analyticsRequest(); Messages.clearSeen();}};
|
||||||
|
|
||||||
|
serverOptions.htmlHook = (html) => {
|
||||||
|
const head = Helmet.rewind();
|
||||||
|
return html.replace('<head>', '<head>'+ head.title + head.meta + head.link);
|
||||||
|
}
|
||||||
|
|
||||||
// ReactRouterSSR.Run(AppRoutes, {historyHook: () => history}, {historyHook: () => history});
|
// ReactRouterSSR.Run(AppRoutes, {historyHook: () => history}, {historyHook: () => history});
|
||||||
ReactRouterSSR.Run(AppRoutes, clientOptions, serverOptions);
|
ReactRouterSSR.Run(AppRoutes, clientOptions, serverOptions);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue