App store mdx support (#2325)

* Adds initial MDX implementation for App Store pages

* Adds endpoint to serve app store static files

* Replaces zoom icon with dynamic-served one

* Fixes zoom icon

* Makes Slider reusable

* Adds gray-matter for MDX

* Adds zoom screenshots

* Update yarn.lock

* Slider improvements

* WIP

* Update TrendingAppsSlider.tsx

* WIP

* Adds MS teams screenshots

* Adds stripe screenshots

* Cleanup

* Update index.ts

* WIP

* Cleanup

* Cleanup

* Adds jitsi screenshot

* Adds Google meet screenshots

* Adds office 365 calendar screenshots

* Adds google calendar screenshots

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-04-04 15:21:33 +01:00
1 parent 26e76df6c8
commit 5dbb60dc85
79 files changed
+2291 -1045

No files matched your search

+56 -2
View File
@@ -1,12 +1,49 @@
import fs from "fs";
import matter from "gray-matter";
import { GetStaticPaths, GetStaticPathsResult, GetStaticPropsContext } from "next";
import { MDXRemote } from "next-mdx-remote";
import { serialize } from "next-mdx-remote/serialize";
import Image from "next/image";
import Link from "next/link";
import path from "path";
import { getAppRegistry } from "@calcom/app-store/_appRegistry";
import useMediaQuery from "@lib/hooks/useMediaQuery";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import App from "@components/App";
import Slider from "@components/apps/Slider";
function SingleAppPage({ data }: inferSSRProps<typeof getStaticProps>) {
const components = {
a: ({ href, ...otherProps }) => (
<Link href={href}>
<a {...otherProps} />
</Link>
),
img: ({ src, alt = "", ...rest }) => <Image src={src} alt={alt} {...rest} />,
Slider: ({ items }) => {
const isTabletAndUp = useMediaQuery("(min-width: 960px)");
return (
<Slider<string>
items={items}
title="Screenshots"
options={{
perView: 1,
}}
renderItem={(item) =>
isTabletAndUp ? (
<Image src={item} alt="" layout="fixed" width={573} height={382} />
) : (
<Image src={item} alt="" layout="responsive" width={573} height={382} />
)
}
/>
);
},
};
function SingleAppPage({ data, source }: inferSSRProps<typeof getStaticProps>) {
return (
<App
name={data.name}
@@ -23,7 +60,7 @@ function SingleAppPage({ data }: inferSSRProps<typeof getStaticProps>) {
email={data.email}
// tos="https://zoom.us/terms"
// privacy="https://zoom.us/privacy"
body={data.description}
body={<MDXRemote {...source} components={components} />}
/>
);
}
@@ -58,8 +95,25 @@ export const getStaticProps = async (ctx: GetStaticPropsContext) => {
};
}
const appDirname = singleApp.type.replace("_", "");
const README_PATH = path.join(process.cwd(), "..", "..", `packages/app-store/${appDirname}/README.mdx`);
const postFilePath = path.join(README_PATH);
let source = "";
try {
/* If the app doesn't have a README we fallback to the packagfe description */
source = fs.readFileSync(postFilePath).toString();
} catch (error) {
console.log("error", error);
source = singleApp.description;
}
const { content, data } = matter(source);
const mdxSource = await serialize(content, { scope: data });
return {
props: {
source: mdxSource,
data: singleApp,
},
};
+2 -2
View File
@@ -7,7 +7,7 @@ import AppsShell from "@components/AppsShell";
import Shell from "@components/Shell";
import AllApps from "@components/apps/AllApps";
import AppStoreCategories from "@components/apps/Categories";
import Slider from "@components/apps/Slider";
import TrendingAppsSlider from "@components/apps/TrendingAppsSlider";
export default function Apps({ appStore, categories }: InferGetStaticPropsType<typeof getStaticProps>) {
const { t } = useLocale();
@@ -16,7 +16,7 @@ export default function Apps({ appStore, categories }: InferGetStaticPropsType<t
<Shell heading={t("app_store")} subtitle={t("app_store_description")} large>
<AppsShell>
<AppStoreCategories categories={categories} />
<Slider items={appStore} />
<TrendingAppsSlider items={appStore} />
<AllApps apps={appStore} />
</AppsShell>
</Shell>