The Node.js® Website
1import type { FC, PropsWithChildren } from 'react';
2
3import AvatarGroup from '@/components/Common/AvatarGroup';
4import Preview from '@/components/Common/Preview';
5import WithBlogCrossLinks from '@/components/withBlogCrossLinks';
6import WithFooter from '@/components/withFooter';
7import WithMetaBar from '@/components/withMetaBar';
8import WithNavBar from '@/components/withNavBar';
9import { useClientContext } from '@/hooks/react-server';
10import ContentLayout from '@/layouts/Content';
11import {
12 mapAuthorToCardAuthors,
13 mapBlogCategoryToPreviewType,
14} from '@/util/blogUtils';
15
16import styles from './layouts.module.css';
17
18const PostLayout: FC<PropsWithChildren> = ({ children }) => {
19 const { frontmatter } = useClientContext();
20
21 const authors = mapAuthorToCardAuthors(frontmatter.author);
22 const type = mapBlogCategoryToPreviewType(frontmatter.category);
23
24 return (
25 <>
26 <WithNavBar />
27
28 <ContentLayout>
29 <div className={styles.postLayout}>
30 <main>
31 <h1>{frontmatter.title}</h1>
32
33 <section>
34 <AvatarGroup
35 avatars={authors.map(author => ({
36 alt: author.fullName,
37 src: author.src,
38 }))}
39 />
40
41 <p>{authors.map(author => author.fullName).join(', ')}</p>
42 </section>
43
44 <Preview title={frontmatter.title!} type={type} />
45
46 {children}
47
48 <WithBlogCrossLinks />
49 </main>
50 </div>
51
52 <WithMetaBar />
53 </ContentLayout>
54
55 <WithFooter />
56 </>
57 );
58};
59
60export default PostLayout;