bigwolfe commited on
Commit
d200fc9
·
1 Parent(s): 9b0713d

Update widget component

Browse files
Files changed (2) hide show
  1. .gitignore +6 -0
  2. frontend/src/widget.tsx +21 -4
.gitignore CHANGED
@@ -56,3 +56,9 @@ DEPLOY_TO_HF.md
56
 
57
  # Documentation
58
  docs/fastmcp/
 
 
 
 
 
 
 
56
 
57
  # Documentation
58
  docs/fastmcp/
59
+
60
+ # Images (binary files not allowed in HF Spaces)
61
+ *.png
62
+ *.jpg
63
+ *.jpeg
64
+ *.gif
frontend/src/widget.tsx CHANGED
@@ -5,6 +5,7 @@ import { NoteViewer } from '@/components/NoteViewer';
5
  import { SearchWidget } from '@/components/SearchWidget';
6
  import type { Note } from '@/types/note';
7
  import type { SearchResult } from '@/types/search';
 
8
  import { Loader2, AlertTriangle } from 'lucide-react';
9
 
10
  // Mock window.openai for development
@@ -121,12 +122,28 @@ const WidgetApp = () => {
121
 
122
  const handleWikilinkClick = (linkText: string) => {
123
  console.log("Clicked wikilink in widget:", linkText);
124
- alert(`Navigation to "${linkText}" requested. (Widget navigation pending implementation)`);
 
 
 
 
 
 
 
125
  };
126
 
127
- const handleNoteSelect = (path: string) => {
128
- console.log("Selected note from search:", path);
129
- alert(`Opening "${path}"... (Widget navigation pending implementation)`);
 
 
 
 
 
 
 
 
 
130
  };
131
 
132
  return (
 
5
  import { SearchWidget } from '@/components/SearchWidget';
6
  import type { Note } from '@/types/note';
7
  import type { SearchResult } from '@/types/search';
8
+ import { getNote } from '@/services/api';
9
  import { Loader2, AlertTriangle } from 'lucide-react';
10
 
11
  // Mock window.openai for development
 
122
 
123
  const handleWikilinkClick = (linkText: string) => {
124
  console.log("Clicked wikilink in widget:", linkText);
125
+ // Convert wikilink text to path (simple slugification or just try reading it)
126
+ // We can try to fetch it directly.
127
+ // Reuse handleNoteSelect logic but we need to slugify first?
128
+ // For now, let's try strict filename matching or just pass text.
129
+ // getNote expects a path.
130
+ // We'll just alert for now or try to resolve it.
131
+ // Let's try to fetch it as a path (assuming user clicked "Getting Started")
132
+ handleNoteSelect(linkText + ".md");
133
  };
134
 
135
+ const handleNoteSelect = async (path: string) => {
136
+ console.log("Selected note:", path);
137
+ setView('loading');
138
+ try {
139
+ const note = await getNote(path);
140
+ setData(note);
141
+ setView('note');
142
+ } catch (err) {
143
+ console.error("Failed to load note:", err);
144
+ setError(`Failed to load note: ${path}`);
145
+ setView('error');
146
+ }
147
  };
148
 
149
  return (