Skip to content

Commit

Permalink
Fix contentlayer builds
Browse files Browse the repository at this point in the history
  • Loading branch information
iipanda committed Oct 24, 2024
1 parent bdf965a commit 21a28f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/www/components/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function PageHeaderDescription({
return (
<p
className={cn(
"text-balance max-w-2xl text-lg font-light text-foreground",
"max-w-2xl text-balance text-lg font-light text-foreground",
className
)}
{...props}
Expand Down
13 changes: 2 additions & 11 deletions apps/www/contentlayer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,10 @@ export const Doc = defineDocumentType(() => ({
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,
Expand All @@ -82,7 +73,7 @@ export default makeSource({
contentDirPath: "./content",
documentTypes: [Doc],
mdx: {
remarkPlugins: [remarkGfm, codeImport],
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
rehypeComponent,
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions apps/www/lib/rehype-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion apps/www/public/r/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message>\n input: string\n className?: string\n handleInputChange: React.ChangeEventHandler<HTMLTextAreaElement>\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 <ChatContainer className={className}>\n {isEmpty && append && suggestions ? (\n <PromptSuggestions append={append} suggestions={suggestions} />\n ) : null}\n\n {messages.length > 0 ? (\n <div\n className=\"relative overflow-y-auto pb-4\"\n ref={containerRef}\n onScroll={handleScroll}\n >\n <MessageList messages={messages} isTyping={isTyping} />\n {!shouldAutoScroll && (\n <div className=\"sticky bottom-0 left-0 flex w-full justify-end\">\n <Button\n onClick={scrollToBottom}\n className=\"h-8 w-8 rounded-full ease-in-out animate-in fade-in-0 slide-in-from-bottom-1\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <ArrowDown className=\"h-4 w-4\" />\n </Button>\n </div>\n )}\n </div>\n ) : null}\n\n <ChatForm\n className=\"mt-auto\"\n isPending={isGenerating || isTyping}\n handleSubmit={handleSubmit}\n >\n {({ files, setFiles }) => (\n <MessageInput\n value={input}\n onChange={handleInputChange}\n allowAttachments\n files={files}\n setFiles={setFiles}\n stop={stop}\n isGenerating={isGenerating}\n />\n )}\n </ChatForm>\n </ChatContainer>\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<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\"grid w-full grid-rows-[1fr_auto]\", className)}\n {...props}\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<React.SetStateAction<File[] | null>>\n }) => ReactElement\n}\n\nconst ChatForm = forwardRef<HTMLFormElement, ChatFormProps>(\n ({ children, handleSubmit, isPending, className }, ref) => {\n const [files, setFiles] = useState<File[] | null>(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 <form ref={ref} onSubmit={onSubmit} className={className}>\n {children({ files, setFiles })}\n </form>\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<Message>\n input: string\n className?: string\n handleInputChange: React.ChangeEventHandler<HTMLTextAreaElement>\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 <ChatContainer className={className}>\n {isEmpty && append && suggestions ? (\n <PromptSuggestions append={append} suggestions={suggestions} />\n ) : null}\n\n {messages.length > 0 ? (\n <ChatMessages messages={messages} isTyping={isTyping} />\n ) : null}\n\n <ChatForm\n className=\"mt-auto\"\n isPending={isGenerating || isTyping}\n handleSubmit={handleSubmit}\n >\n {({ files, setFiles }) => (\n <MessageInput\n value={input}\n onChange={handleInputChange}\n allowAttachments\n files={files}\n setFiles={setFiles}\n stop={stop}\n isGenerating={isGenerating}\n />\n )}\n </ChatForm>\n </ChatContainer>\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 <div\n className=\"relative overflow-y-auto pb-4\"\n ref={containerRef}\n onScroll={handleScroll}\n >\n <MessageList messages={messages} isTyping={isTyping} />\n {!shouldAutoScroll && (\n <div className=\"sticky bottom-0 left-0 flex w-full justify-end\">\n <Button\n onClick={scrollToBottom}\n className=\"h-8 w-8 rounded-full ease-in-out animate-in fade-in-0 slide-in-from-bottom-1\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <ArrowDown className=\"h-4 w-4\" />\n </Button>\n </div>\n )}\n </div>\n )\n}\n\nconst ChatContainer = forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\"grid w-full grid-rows-[1fr_auto]\", className)}\n {...props}\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<React.SetStateAction<File[] | null>>\n }) => ReactElement\n}\n\nconst ChatForm = forwardRef<HTMLFormElement, ChatFormProps>(\n ({ children, handleSubmit, isPending, className }, ref) => {\n const [files, setFiles] = useState<File[] | null>(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 <form ref={ref} onSubmit={onSubmit} className={className}>\n {children({ files, setFiles })}\n </form>\n )\n }\n)\nChatForm.displayName = \"ChatForm\"\n",
"type": "registry:ui",
"target": ""
}
Expand Down

0 comments on commit 21a28f0

Please sign in to comment.