|
1 | | -import { ExampleComponent } from 'components/ExampleComponent' |
| 1 | +import { GetServerSideProps } from 'next' |
2 | 2 |
|
3 | | -const CategoryPage = () => { |
| 3 | +import { |
| 4 | + MainContextT, |
| 5 | + MainContext, |
| 6 | + getMainContextFromRequest, |
| 7 | +} from 'components/context/MainContext' |
| 8 | +import { DefaultLayout } from 'components/DefaultLayout' |
| 9 | +import { |
| 10 | + getProductLandingContextFromRequest, |
| 11 | + ProductLandingContextT, |
| 12 | + ProductLandingContext, |
| 13 | + useProductLandingContext, |
| 14 | +} from 'components/context/ProductLandingContext' |
| 15 | + |
| 16 | +import { LandingHero } from 'components/landing/LandingHero' |
| 17 | +import { FeaturedArticles } from 'components/landing/FeaturedArticles' |
| 18 | +import { GuideCards } from 'components/landing/GuideCards' |
| 19 | +import { SponsorsExamples } from 'components/landing/SponsorsExamples' |
| 20 | +import { CommunityExamples } from 'components/landing/CommunityExamples' |
| 21 | +import { LandingSection } from 'components/landing/LandingSection' |
| 22 | +import { useTranslation } from 'components/hooks/useTranslation' |
| 23 | + |
| 24 | +type Props = { |
| 25 | + mainContext: MainContextT |
| 26 | + productLandingContext: ProductLandingContextT |
| 27 | +} |
| 28 | +const ProductPage = ({ mainContext, productLandingContext }: Props) => { |
4 | 29 | return ( |
5 | | - <div className="p-4"> |
6 | | - <h1>Sample category page</h1> |
7 | | - <ExampleComponent /> |
8 | | - </div> |
| 30 | + <MainContext.Provider value={mainContext}> |
| 31 | + <ProductLandingContext.Provider value={productLandingContext}> |
| 32 | + <ProductPageInner /> |
| 33 | + </ProductLandingContext.Provider> |
| 34 | + </MainContext.Provider> |
9 | 35 | ) |
10 | 36 | } |
11 | 37 |
|
12 | | -export default CategoryPage |
| 38 | +const ProductPageInner = () => { |
| 39 | + const { guideCards, productUserExamples, productCommunityExamples } = useProductLandingContext() |
| 40 | + const { t } = useTranslation('product_landing') |
| 41 | + |
| 42 | + return ( |
| 43 | + <DefaultLayout> |
| 44 | + <LandingSection className="pt-3"> |
| 45 | + <LandingHero /> |
| 46 | + </LandingSection> |
| 47 | + |
| 48 | + <LandingSection> |
| 49 | + <FeaturedArticles /> |
| 50 | + </LandingSection> |
| 51 | + |
| 52 | + {/* {% if productCodeExamples %} |
| 53 | + {% include code-examples %} |
| 54 | + {% endif %} |
| 55 | + */} |
| 56 | + |
| 57 | + {productCommunityExamples.length > 0 && ( |
| 58 | + <LandingSection title={t('communities_using_discussions')} className="my-6"> |
| 59 | + <CommunityExamples /> |
| 60 | + </LandingSection> |
| 61 | + )} |
| 62 | + |
| 63 | + {productUserExamples.length > 0 && ( |
| 64 | + <LandingSection title={t('sponsor_community')} className="my-6"> |
| 65 | + <SponsorsExamples /> |
| 66 | + </LandingSection> |
| 67 | + )} |
| 68 | + |
| 69 | + {guideCards.length > 0 && ( |
| 70 | + <div className="bg-guides-gradient py-6"> |
| 71 | + <LandingSection title={t('guides')} className="my-6"> |
| 72 | + <GuideCards /> |
| 73 | + </LandingSection> |
| 74 | + </div> |
| 75 | + )} |
| 76 | + |
| 77 | + {/* <PageSection title="All GitHub Sponsors Docs"> |
| 78 | + <SiteTreeGrid /> |
| 79 | + </PageSection> */} |
| 80 | + </DefaultLayout> |
| 81 | + ) |
| 82 | +} |
| 83 | + |
| 84 | +export default ProductPage |
| 85 | + |
| 86 | +export const getServerSideProps: GetServerSideProps<Props> = async (context) => { |
| 87 | + const req = context.req as any |
| 88 | + |
| 89 | + return { |
| 90 | + props: { |
| 91 | + mainContext: getMainContextFromRequest(req), |
| 92 | + productLandingContext: getProductLandingContextFromRequest(req), |
| 93 | + }, |
| 94 | + } |
| 95 | +} |
0 commit comments