The Node.js® Website
1import type { ClientSharedServerContext } from '@/types';
2
3export const assignClientContext = <T extends ClientSharedServerContext>(
4 props: Partial<T>
5) =>
6 ({
7 frontmatter: props.frontmatter ?? {},
8 pathname: props.pathname ?? '',
9 headings: props.headings ?? [],
10 readingTime: props.readingTime ?? {
11 text: '',
12 minutes: 0,
13 time: 0,
14 words: 0,
15 },
16 filename: props.filename ?? '',
17 }) as T;