www-new/components/OrganizedContent/Section.tsx

60 lines
1.2 KiB
TypeScript

import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote";
import React, { ComponentType } from "react";
import {
createLink,
LinkProps,
OrganizedContent,
} from "@/components/OrganizedContent";
import { GetShapesConfig } from "../ShapesBackground";
import { Header } from "./Header";
interface Section {
id: string;
title: string;
}
export interface Props {
content: MDXRemoteSerializeResult;
sections: Section[];
current: number;
}
export interface Options {
title: string;
pagePath: string;
image: string;
getShapesConfig: GetShapesConfig;
link?: ComponentType<LinkProps>;
}
export function createSectionPage({
title,
image,
pagePath,
getShapesConfig,
link,
}: Options) {
const Link = link ?? createLink(pagePath);
function Page(this: void, { content, sections, current }: Props) {
return (
<Header title={title} image={image}>
<OrganizedContent
sections={sections}
id={sections[current].id}
link={Link}
>
<MDXRemote {...content} />
</OrganizedContent>
</Header>
);
}
Page.getShapesConfig = getShapesConfig;
return Page;
}