-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a custom homepage updates required #954
Comments
Here's a functoinal import React, { Component } from "react";
import PropTypes from "prop-types";
import inject from "hocs/inject";
import Helmet from "react-helmet";
import HomePage from "custom/components/HomePage";
import Layout from "components/Layout";
import { withApollo } from "lib/apollo/withApollo";
import { locales } from "translations/config";
import fetchPrimaryShop from "staticUtils/shop/fetchPrimaryShop";
import fetchTranslations from "staticUtils/translations/fetchTranslations";
class Home extends Component {
static propTypes = {
routingStore: PropTypes.object,
shop: PropTypes.shape({
currency: PropTypes.shape({
code: PropTypes.string.isRequired
})
})
};
render() {
const { shop } = this.props;
return (
<Layout shop={shop}>
<Helmet
title={shop && shop.name}
meta={[{ name: "description", content: shop && shop.description }]}
/>
<HomePage />
</Layout>
);
}
}
/**
* Static props for the cart
*
* @returns {Object} the props
*/
export async function getStaticProps({ params: { lang } }) {
return {
props: {
...await fetchPrimaryShop(lang),
...await fetchTranslations(lang, ["common"])
}
};
}
/**
* Static paths for the cart
*
* @returns {Object} the paths
*/
export async function getStaticPaths() {
return {
paths: locales.map((locale) => ({ params: { lang: locale } })),
fallback: false
};
}
export default withApollo()(inject("routingStore")(Home)); Note with the introduction of i18n this now goes in |
ghost
mentioned this issue
Jul 28, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type: minor
Describe the bug
The changes in release reactioncommerce/example-storefront#688 will invalidate the current documentation. Need to remove the MobX dep, replace decorators with composition, switch to using
useApollo
HOC and addgetStaticProps
andgetStaticPaths
exports tohome.js
. Also, with the routing changes made for the newi18nRouter
the routing instructions need to be updated.I was able to ad lib with what's there now to create a new homepage but it's not clear how to adjust the router now so the homepage appears at the shop base url.
To Reproduce
Steps to reproduce the behavior:
release-next-v3.2.0
branch ofexample-storefront
.docker-comose.dev.yml
Expected behavior
Documentation is updated to reflect refactoring upon release
Depends on
reactioncommerce/example-storefront#703
reactioncommerce/example-storefront#704
The text was updated successfully, but these errors were encountered: