This commit is contained in:
f-trycua
2025-11-12 19:43:04 +01:00
parent bf36bfc3b0
commit ed9005075f
4 changed files with 30 additions and 8 deletions

View File

@@ -5,7 +5,14 @@ import { z } from 'zod';
// see https://fumadocs.vercel.app/docs/mdx/collections#define-docs
export const docs = defineDocs({
docs: {
schema: frontmatterSchema,
schema: frontmatterSchema.extend({
macos: z.boolean().optional(),
windows: z.boolean().optional(),
linux: z.boolean().optional(),
pypi: z.string().optional(),
npm: z.string().optional(),
github: z.array(z.string()).optional(),
}),
},
meta: {
schema: metaSchema,

View File

@@ -187,7 +187,7 @@ export default async function Page(props: { params: Promise<{ slug?: string[] }>
const tocFooter = () => {
return (
<div className="mt-4">
<DocActionsMenu pageUrl={page.url} pageTitle={page.data.title} filePath={page.file?.path} />
<DocActionsMenu pageUrl={page.url} pageTitle={page.data.title} filePath={undefined} />
</div>
);
};

View File

@@ -7,7 +7,7 @@ import posthog from 'posthog-js';
interface DocActionsMenuProps {
pageUrl: string;
pageTitle: string;
filePath: string;
filePath?: string;
}
export function DocActionsMenu({ pageUrl, pageTitle, filePath }: DocActionsMenuProps) {
@@ -15,6 +15,9 @@ export function DocActionsMenu({ pageUrl, pageTitle, filePath }: DocActionsMenuP
const handleCopyMarkdown = async () => {
try {
if (!filePath) {
throw new Error('No file path available');
}
const githubRawUrl = `https://raw.githubusercontent.com/trycua/cua/refs/heads/main/docs/content/docs/${filePath}`;
const response = await fetch(githubRawUrl);
@@ -55,6 +58,9 @@ export function DocActionsMenu({ pageUrl, pageTitle, filePath }: DocActionsMenuP
};
const handleEditGithub = () => {
if (!filePath) {
return;
}
posthog.capture('docs_edit_github_clicked', {
page: pageUrl,
page_title: pageTitle,

View File

@@ -12,15 +12,24 @@ const processor = remark()
.use(remarkGfm);
export async function getLLMText(page: InferPageType<typeof source>) {
const processed = await processor.process({
path: page.data._file.absolutePath,
value: page.data.content,
});
const pageData = page.data as any;
const filePath = pageData._file?.absolutePath;
const content = pageData.content || pageData.body || '';
let processed;
if (filePath && typeof content === 'string') {
processed = await processor.process({ path: filePath, value: content });
} else if (typeof content === 'string') {
processed = await processor.process(content);
} else {
// Handle case where content is not available
processed = { value: '' };
}
return `# ${page.data.title}
URL: ${page.url}
${page.data.description}
${page.data.description || ''}
${processed.value}`;
}