export const componentPreviewerTemplate = (
imports: string,
code: string,
argTypes: string,
reactLive: string,
nativeOnly?: boolean
) => `import { ComponentPreviewer } from '@/components/custom/component-previewer';
${imports}
export default function Example() {
return (
);
}`;
export const pageContentTemplate = `
"use client";
import Docs from './index.mdx';
export default function Page() {
return (
);
}`;
export const codePreviewerTemplate = (
code: string,
argTypes: string,
reactLive: string,
title: string,
description: string,
importMap: Record,
nativeOnly?: boolean
) =>
`
${title && title.toLowerCase() !== 'basic' ? `#### ${title}` : ''}
${description && `${description}`}
`;
export const layoutTemplate = (frontMatter: Record) => {
const { title, description } = frontMatter;
return `
import React from 'react';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: ${JSON.stringify(title || '')},
description: ${JSON.stringify(description || '')}
}
export default function Layout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
{children}
>
);
}`;
};
export const createAllComponentsTemplate = (
components: string[],
componentMap: string,
componentsNameList: string[]
) => {
return `import React from 'react';;
import { Grid,GridItem } from '@/components/ui/grid';
import { Box } from '@/components/ui/box';
import { Text } from '@/components/ui/text';
${componentMap}
const componentsList = [${components}];
const componentsNameList = ${JSON.stringify(componentsNameList)};
export default function AllComponents() {
return (
{componentsNameList.map((componentName,index) => {
const Component = componentsList[index];
return (
{
window.location.href = \`/ui/docs/components/\${componentName}\`;
}}
>
{componentName}
);
})}
);
}
`;
};