@@ -82,12 +85,17 @@ export default async function NoteDetailPage({ params }: { params: Promise<{ id:
)}
-
+
{related.length > 0 && (
)}
+ >
)
}
\ No newline at end of file
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 6900476..a9b0719 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,37 +1,19 @@
-import { prisma } from '@/lib/prisma'
import { Dashboard } from '@/components/dashboard'
-import { NoteType } from '@/types/note'
-
-async function getNotes() {
- const notes = await prisma.note.findMany({
- include: { tags: { include: { tag: true } } },
- orderBy: { updatedAt: 'desc' },
- })
- return notes
-}
+import { getDashboardData } from '@/lib/dashboard'
export default async function HomePage() {
- const allNotes = await getNotes()
-
- const notesWithTags = allNotes.map(note => ({
- ...note,
- createdAt: note.createdAt.toISOString(),
- updatedAt: note.updatedAt.toISOString(),
- type: note.type as NoteType,
- tags: note.tags.map(nt => ({ tag: nt.tag })),
- }))
-
- const recentNotes = notesWithTags.slice(0, 6)
- const favoriteNotes = notesWithTags.filter(n => n.isFavorite)
- const pinnedNotes = notesWithTags.filter(n => n.isPinned)
+ const data = await getDashboardData(6)
return (
)
-}
\ No newline at end of file
+}
diff --git a/src/components/dashboard.tsx b/src/components/dashboard.tsx
index 6bba4b1..6d7ba30 100644
--- a/src/components/dashboard.tsx
+++ b/src/components/dashboard.tsx
@@ -5,13 +5,25 @@ import { Note } from '@/types/note'
import { NoteList } from './note-list'
import { Button } from '@/components/ui/button'
import { SearchBar } from './search-bar'
-import { ArrowRight } from 'lucide-react'
+import { ArrowRight, TrendingUp, Terminal, Code, Zap } from 'lucide-react'
-export function Dashboard({ recentNotes, favoriteNotes, pinnedNotes }: {
+interface DashboardProps {
recentNotes: Note[]
- favoriteNotes: Note[]
- pinnedNotes: Note[]
-}) {
+ mostUsedNotes: Note[]
+ recentCommands: Note[]
+ recentSnippets: Note[]
+ activityBasedNotes: Note[]
+ hasActivity: boolean
+}
+
+export function Dashboard({
+ recentNotes,
+ mostUsedNotes,
+ recentCommands,
+ recentSnippets,
+ activityBasedNotes,
+ hasActivity,
+}: DashboardProps) {
return (
<>
@@ -19,27 +31,12 @@ export function Dashboard({ recentNotes, favoriteNotes, pinnedNotes }: {
- {pinnedNotes.length > 0 && (
-
- )}
-
- {favoriteNotes.length > 0 && (
-
- )}
-
+ {/* Recientes */}
-
Recientes
+
+ Recientes
+
>
)
-}
\ No newline at end of file
+}
+
+function EmptyState() {
+ return (
+
+
No hay notas todavía.
+
+
Crea tu primera nota
+
+
+ )
+}
diff --git a/src/components/markdown-content.tsx b/src/components/markdown-content.tsx
index 3ff4b3f..0124efd 100644
--- a/src/components/markdown-content.tsx
+++ b/src/components/markdown-content.tsx
@@ -8,19 +8,24 @@ import { NoteType } from '@/types/note'
import { Copy, Check } from 'lucide-react'
import { useState } from 'react'
import { cn } from '@/lib/utils'
+import { trackNoteUsage } from '@/lib/usage'
interface MarkdownContentProps {
content: string
className?: string
noteType?: NoteType
+ noteId?: string
}
-function CopyButton({ text }: { text: string }) {
+function CopyButton({ text, noteId, eventType }: { text: string; noteId?: string; eventType?: 'copy_command' | 'copy_snippet' }) {
const [copied, setCopied] = useState(false)
const handleCopy = async () => {
await navigator.clipboard.writeText(text)
setCopied(true)
+ if (noteId && eventType) {
+ trackNoteUsage({ noteId, eventType })
+ }
setTimeout(() => setCopied(false), 2000)
}
@@ -88,7 +93,7 @@ function ProcedureCheckboxes({ content }: { content: string }) {
)
}
-export function MarkdownContent({ content, className = '', noteType }: MarkdownContentProps) {
+export function MarkdownContent({ content, className = '', noteType, noteId }: MarkdownContentProps) {
if (noteType === 'procedure') {
return (
@@ -118,7 +123,7 @@ export function MarkdownContent({ content, className = '', noteType }: MarkdownC
>
{codeString}
-
+
)
}
@@ -134,7 +139,7 @@ export function MarkdownContent({ content, className = '', noteType }: MarkdownC
>
{codeString}
-
+
)
}
@@ -157,7 +162,7 @@ export function MarkdownContent({ content, className = '', noteType }: MarkdownC
>
{codeString}
-
+
)
},
diff --git a/src/components/track-note-view.tsx b/src/components/track-note-view.tsx
new file mode 100644
index 0000000..cc4f739
--- /dev/null
+++ b/src/components/track-note-view.tsx
@@ -0,0 +1,12 @@
+'use client'
+
+import { useEffect } from 'react'
+import { addToRecentlyViewed } from '@/lib/usage'
+
+export function TrackNoteView({ noteId }: { noteId: string }) {
+ useEffect(() => {
+ addToRecentlyViewed(noteId)
+ }, [noteId])
+
+ return null
+}
diff --git a/src/lib/dashboard.ts b/src/lib/dashboard.ts
new file mode 100644
index 0000000..9b71b77
--- /dev/null
+++ b/src/lib/dashboard.ts
@@ -0,0 +1,103 @@
+import { prisma } from '@/lib/prisma'
+import { getRecentlyUsedNotes } from '@/lib/usage'
+import { NoteType } from '@/types/note'
+
+export interface DashboardNote {
+ id: string
+ title: string
+ content: string
+ type: NoteType
+ isFavorite: boolean
+ isPinned: boolean
+ createdAt: string
+ updatedAt: string
+ tags: { tag: { id: string; name: string } }[]
+ usageCount?: number
+}
+
+export interface DashboardData {
+ recentNotes: DashboardNote[]
+ mostUsedNotes: DashboardNote[]
+ recentCommands: DashboardNote[]
+ recentSnippets: DashboardNote[]
+ activityBasedNotes: DashboardNote[]
+ hasActivity: boolean
+}
+
+export async function getDashboardData(limit = 6): Promise