site: fix

This commit is contained in:
Benjy Cui 2016-06-03 15:26:25 +08:00
parent f99a77b3e5
commit 5be40a9c7f
3 changed files with 36 additions and 16 deletions

View File

@ -126,7 +126,7 @@
"clean": "antd-tools run clean",
"start": "bisheng start -c ./site/bisheng.config.js",
"site": "bisheng build -c ./site/bisheng.config.js",
"pre-deploy": "cp CNAME _site",
"pre-deploy": "mkdir -p _site && cp CNAME _site",
"deploy": "tnpm run clean && tnpm i && tnpm run just-deploy",
"just-deploy": "tnpm run pre-deploy && bisheng gh-pages -c ./site/bisheng.config.js",
"lint": "npm run srclint && npm run demolint && npm run lesshint",

View File

@ -9,6 +9,13 @@ import Page3 from './Page3';
import Page4 from './Page4';
export default class Home extends React.Component {
componentWillMount() {
if (location.hash) {
const pathname = location.hash.replace(/^#/, '').replace('?scrollTo=', '#');
location.href = pathname;
}
}
// To store style which is only for Home and has conflicts with others.
getStyle() {
return `

View File

@ -22,10 +22,6 @@ if (!location.port) {
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-72788897-1', 'auto');
ga('send', 'pageview');
appHistory.listen((loc) => {
ga('send', 'pageview', loc.pathname + loc.search);
});
/* eslint-enable */
}
@ -58,14 +54,31 @@ const isZhCN = (typeof localStorage !== 'undefined' && localStorage.getItem('loc
const appLocale = isZhCN ? cnLocale : enLocale;
addLocaleData(appLocale.data);
export default (props) => {
return (
<IntlProvider locale={appLocale.locale} messages={appLocale.messages}>
<div className="page-wrapper">
<Header {...props} />
{props.children}
<Footer />
</div>
</IntlProvider>
);
};
let gaListenerSetted = false;
export default class Layout extends React.Component {
static contextTypes = {
router: React.PropTypes.object.isRequired,
}
componentDidMount() {
if (typeof ga !== 'undefined' && !gaListenerSetted) {
this.context.router.listen((loc) => {
window.ga('send', 'pageview', loc.pathname + loc.search);
});
gaListenerSetted = true;
}
}
render() {
const props = this.props;
return (
<IntlProvider locale={appLocale.locale} messages={appLocale.messages}>
<div className="page-wrapper">
<Header {...props} />
{props.children}
<Footer />
</div>
</IntlProvider>
);
}
}