From 21a28f00e1a9eaf0db777b6fb3c8288ad900a974 Mon Sep 17 00:00:00 2001 From: Karol Chudzik Date: Thu, 24 Oct 2024 10:18:32 +0200 Subject: [PATCH] Fix contentlayer builds --- apps/www/components/page-header.tsx | 2 +- apps/www/contentlayer.config.js | 13 ++----------- apps/www/lib/rehype-component.ts | 2 ++ apps/www/public/r/chat.json | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/apps/www/components/page-header.tsx b/apps/www/components/page-header.tsx index 70726d2f..c8bbda93 100644 --- a/apps/www/components/page-header.tsx +++ b/apps/www/components/page-header.tsx @@ -40,7 +40,7 @@ function PageHeaderDescription({ return (

({ type: "string", required: true, }, - published: { - type: "boolean", - default: true, - }, links: { type: "nested", of: LinksProperties, }, - featured: { - type: "boolean", - default: false, - required: false, - }, component: { type: "boolean", default: false, @@ -82,7 +73,7 @@ export default makeSource({ contentDirPath: "./content", documentTypes: [Doc], mdx: { - remarkPlugins: [remarkGfm, codeImport], + remarkPlugins: [remarkGfm], rehypePlugins: [ rehypeSlug, rehypeComponent, @@ -123,7 +114,7 @@ export default makeSource({ } }, onVisitHighlightedLine(node) { - node.properties.className.push("line--highlighted") + node.properties.className = ["line--highlighted"] }, onVisitHighlightedWord(node) { node.properties.className = ["word--highlighted"] diff --git a/apps/www/lib/rehype-component.ts b/apps/www/lib/rehype-component.ts index d8eec15d..7368f98e 100644 --- a/apps/www/lib/rehype-component.ts +++ b/apps/www/lib/rehype-component.ts @@ -34,6 +34,7 @@ export function rehypeComponent() { src = srcPath } else { const component = Index[name] + console.log(":37", component) src = fileName ? component.files.find((file: string) => { return ( @@ -97,6 +98,7 @@ export function rehypeComponent() { try { const component = Index[name] + console.log(":101", component) const src = component.files[0] // Read the source file. diff --git a/apps/www/public/r/chat.json b/apps/www/public/r/chat.json index 0ab9a71b..1ad72afa 100644 --- a/apps/www/public/r/chat.json +++ b/apps/www/public/r/chat.json @@ -12,7 +12,7 @@ "files": [ { "path": "ui/chat.tsx", - "content": "\"use client\"\n\nimport { forwardRef, useState, type ReactElement } from \"react\"\nimport { ArrowDown } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { useAutoScroll } from \"@/registry/default/hooks/use-auto-scroll\"\nimport { Button } from \"@/registry/default/ui/button\"\nimport { type Message } from \"@/registry/default/ui/chat-message\"\nimport { MessageInput } from \"@/registry/default/ui/message-input\"\nimport { MessageList } from \"@/registry/default/ui/message-list\"\n\nimport { PromptSuggestions } from \"./prompt-suggestions\"\n\ninterface ChatPropsBase {\n handleSubmit: (\n event?: { preventDefault?: () => void },\n options?: { experimental_attachments?: FileList }\n ) => void\n messages: Array\n input: string\n className?: string\n handleInputChange: React.ChangeEventHandler\n isGenerating: boolean\n stop?: () => void\n}\n\ninterface ChatPropsWithoutSuggestions extends ChatPropsBase {\n append?: never\n suggestions?: never\n}\n\ninterface ChatPropsWithSuggestions extends ChatPropsBase {\n append: (message: { role: \"user\"; content: string }) => void\n suggestions: string[]\n}\n\ntype ChatProps = ChatPropsWithoutSuggestions | ChatPropsWithSuggestions\n\nexport function Chat({\n messages,\n handleSubmit,\n input,\n handleInputChange,\n stop,\n isGenerating,\n append,\n suggestions,\n className,\n}: ChatProps) {\n const lastMessage = messages.at(-1)\n const isEmpty = messages.length === 0\n const isTyping = lastMessage?.role === \"user\"\n\n const { containerRef, scrollToBottom, handleScroll, shouldAutoScroll } =\n useAutoScroll([messages])\n\n return (\n \n {isEmpty && append && suggestions ? (\n \n ) : null}\n\n {messages.length > 0 ? (\n \n \n {!shouldAutoScroll && (\n

\n \n \n \n
\n )}\n \n ) : null}\n\n \n {({ files, setFiles }) => (\n \n )}\n \n \n )\n}\nChat.displayName = \"Chat\"\n\nfunction createFileList(files: File[] | FileList): FileList {\n const dataTransfer = new DataTransfer()\n for (const file of Array.from(files)) {\n dataTransfer.items.add(file)\n }\n return dataTransfer.files\n}\n\nconst ChatContainer = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => {\n return (\n \n )\n})\nChatContainer.displayName = \"ChatContainer\"\n\ninterface ChatFormProps {\n className?: string\n isPending: boolean\n handleSubmit: (\n event?: { preventDefault?: () => void },\n options?: { experimental_attachments?: FileList }\n ) => void\n children: (props: {\n files: File[] | null\n setFiles: React.Dispatch>\n }) => ReactElement\n}\n\nconst ChatForm = forwardRef(\n ({ children, handleSubmit, isPending, className }, ref) => {\n const [files, setFiles] = useState(null)\n\n const onSubmit = (event: React.FormEvent) => {\n if (isPending) {\n event.preventDefault()\n return\n }\n\n if (!files) {\n handleSubmit(event)\n return\n }\n\n const fileList = createFileList(files)\n handleSubmit(event, { experimental_attachments: fileList })\n setFiles(null)\n }\n\n return (\n
\n {children({ files, setFiles })}\n
\n )\n }\n)\nChatForm.displayName = \"ChatForm\"\n", + "content": "\"use client\"\n\nimport { forwardRef, useState, type ReactElement } from \"react\"\nimport { ArrowDown } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { useAutoScroll } from \"@/registry/default/hooks/use-auto-scroll\"\nimport { Button } from \"@/registry/default/ui/button\"\nimport { type Message } from \"@/registry/default/ui/chat-message\"\nimport { MessageInput } from \"@/registry/default/ui/message-input\"\nimport { MessageList } from \"@/registry/default/ui/message-list\"\n\nimport { PromptSuggestions } from \"./prompt-suggestions\"\n\ninterface ChatPropsBase {\n handleSubmit: (\n event?: { preventDefault?: () => void },\n options?: { experimental_attachments?: FileList }\n ) => void\n messages: Array\n input: string\n className?: string\n handleInputChange: React.ChangeEventHandler\n isGenerating: boolean\n stop?: () => void\n}\n\ninterface ChatPropsWithoutSuggestions extends ChatPropsBase {\n append?: never\n suggestions?: never\n}\n\ninterface ChatPropsWithSuggestions extends ChatPropsBase {\n append: (message: { role: \"user\"; content: string }) => void\n suggestions: string[]\n}\n\ntype ChatProps = ChatPropsWithoutSuggestions | ChatPropsWithSuggestions\n\nexport function Chat({\n messages,\n handleSubmit,\n input,\n handleInputChange,\n stop,\n isGenerating,\n append,\n suggestions,\n className,\n}: ChatProps) {\n const lastMessage = messages.at(-1)\n const isEmpty = messages.length === 0\n const isTyping = lastMessage?.role === \"user\"\n\n return (\n \n {isEmpty && append && suggestions ? (\n \n ) : null}\n\n {messages.length > 0 ? (\n \n ) : null}\n\n \n {({ files, setFiles }) => (\n \n )}\n \n \n )\n}\nChat.displayName = \"Chat\"\n\nfunction createFileList(files: File[] | FileList): FileList {\n const dataTransfer = new DataTransfer()\n for (const file of Array.from(files)) {\n dataTransfer.items.add(file)\n }\n return dataTransfer.files\n}\n\nfunction ChatMessages({\n messages,\n isTyping,\n}: {\n messages: Message[]\n isTyping: boolean\n}) {\n const { containerRef, scrollToBottom, handleScroll, shouldAutoScroll } =\n useAutoScroll([messages])\n\n return (\n \n \n {!shouldAutoScroll && (\n
\n \n \n \n
\n )}\n \n )\n}\n\nconst ChatContainer = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => {\n return (\n \n )\n})\nChatContainer.displayName = \"ChatContainer\"\n\ninterface ChatFormProps {\n className?: string\n isPending: boolean\n handleSubmit: (\n event?: { preventDefault?: () => void },\n options?: { experimental_attachments?: FileList }\n ) => void\n children: (props: {\n files: File[] | null\n setFiles: React.Dispatch>\n }) => ReactElement\n}\n\nconst ChatForm = forwardRef(\n ({ children, handleSubmit, isPending, className }, ref) => {\n const [files, setFiles] = useState(null)\n\n const onSubmit = (event: React.FormEvent) => {\n if (isPending) {\n event.preventDefault()\n return\n }\n\n if (!files) {\n handleSubmit(event)\n return\n }\n\n const fileList = createFileList(files)\n handleSubmit(event, { experimental_attachments: fileList })\n setFiles(null)\n }\n\n return (\n
\n {children({ files, setFiles })}\n
\n )\n }\n)\nChatForm.displayName = \"ChatForm\"\n", "type": "registry:ui", "target": "" }