Spaces:
Sleeping
Sleeping
File size: 25,292 Bytes
fa7b380 a35961c fa7b380 82e88b6 e94f914 a35961c fa7b380 a35961c fa7b380 82e88b6 a35961c fa7b380 a35961c fa7b380 e94f914 a35961c e94f914 fa7b380 a35961c fa7b380 82e88b6 a35961c 82e88b6 fa7b380 e94f914 a35961c e94f914 a35961c e94f914 fa7b380 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | import { createFileRoute } from "@tanstack/react-router";
import { useState, useMemo, useEffect } from "react";
import { useMutation } from "@tanstack/react-query";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Checkbox } from "@/components/ui/checkbox";
import { Badge } from "@/components/ui/badge";
import { Plus, ChevronLeft, ChevronRight, Download, Search, Trash2, Loader2 } from "lucide-react";
import { useSites } from "@/lib/grabber/useSites";
import { searchPosts } from "@/lib/grabber/search.functions";
import type { NormalizedPost } from "@/lib/grabber/sites";
import { AddSiteDialog } from "@/components/grabber/AddSiteDialog";
import { Lightbox } from "@/components/grabber/Lightbox";
export const Route = createFileRoute("/")({
head: () => ({
meta: [
{ title: "Imageboard Grabber" },
{
name: "description",
content: "Search booru-style imageboards, browse thumbnails, and batch-download as ZIP.",
},
{ property: "og:title", content: "Imageboard Grabber" },
{
property: "og:description",
content: "Search booru-style imageboards, browse thumbnails, and batch-download as ZIP.",
},
],
}),
component: Grabber,
});
function Grabber() {
const { sites, custom, addSite, removeSite, hydrated } = useSites();
const [siteId, setSiteId] = useState("e621");
const [tags, setTags] = useState("");
const [limit, setLimit] = useState(40);
const [page, setPage] = useState(1);
const [selected, setSelected] = useState<Set<string>>(new Set());
const [addOpen, setAddOpen] = useState(false);
const [lightbox, setLightbox] = useState<NormalizedPost | null>(null);
const [downloading, setDownloading] = useState(false);
const [excludeTags, setExcludeTags] = useState("");
const [hfToken, setHfToken] = useState("");
const [datasetName, setDatasetName] = useState("");
const [uploading, setUploading] = useState(false);
const [uploadStatus, setUploadStatus] = useState("");
const [customFilename, setCustomFilename] = useState("");
const [customSubfolder, setCustomSubfolder] = useState("");
const [e621Username, setE621Username] = useState("");
const [e621ApiKey, setE621ApiKey] = useState("");
const [autocompleteEnabled, setAutocompleteEnabled] = useState(true);
const [activeTagFile, setActiveTagFile] = useState("tags-selected.csv");
const [availableTagFiles, setAvailableTagFiles] = useState<string[]>([]);
const [newTagFileUrl, setNewTagFileUrl] = useState("");
const [downloadingTagFile, setDownloadingTagFile] = useState(false);
const [tagSuggestions, setTagSuggestions] = useState<{ name: string; count: number }[]>([]);
const [activeWordInfo, setActiveWordInfo] = useState<{ word: string; start: number; end: number } | null>(null);
const [focusedSuggestionIdx, setFocusedSuggestionIdx] = useState(-1);
const fetchTagFiles = async () => {
try {
const res = await fetch("/api/tags?action=list");
const data = await res.json();
if (data.success && Array.isArray(data.files)) {
setAvailableTagFiles(data.files);
if (data.files.length > 0 && !data.files.includes(activeTagFile)) {
// Default to tags-selected.csv if available
if (data.files.includes("tags-selected.csv")) {
setActiveTagFile("tags-selected.csv");
} else {
setActiveTagFile(data.files[0]);
}
}
}
} catch (err) {
console.error("Failed to list tag files:", err);
}
};
const handleDownloadTagFile = async () => {
if (!newTagFileUrl.trim()) return;
setDownloadingTagFile(true);
try {
const res = await fetch("/api/tags", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ downloadUrl: newTagFileUrl.trim() }),
});
const data = await res.json();
if (!res.ok) {
alert(`Error: ${data.error}`);
} else {
alert(`Successfully downloaded and decompressed ${data.filename}!`);
setNewTagFileUrl("");
await fetchTagFiles();
setActiveTagFile(data.filename);
}
} catch (err) {
alert(`Download failed: ${err instanceof Error ? err.message : "unknown error"}`);
} finally {
setDownloadingTagFile(false);
}
};
const updateActiveWord = (el: HTMLInputElement) => {
const val = el.value;
const pos = el.selectionStart;
if (pos === null || !autocompleteEnabled) {
setTagSuggestions([]);
setActiveWordInfo(null);
return;
}
// Find start and end of word under cursor
let start = pos;
while (start > 0 && !/\s/.test(val[start - 1])) {
start--;
}
let end = pos;
while (end < val.length && !/\s/.test(val[end])) {
end++;
}
const word = val.slice(start, end).trim();
// Exclude colon commands like rating:safe
if (word && !word.includes(":")) {
setActiveWordInfo({ word, start, end });
} else {
setTagSuggestions([]);
setActiveWordInfo(null);
}
};
const selectSuggestion = (tagName: string) => {
if (!activeWordInfo) return;
const before = tags.slice(0, activeWordInfo.start);
const after = tags.slice(activeWordInfo.end);
// Replace word and add a trailing space
const newTags = before + tagName + " " + (after.trim() ? after : "");
setTags(newTags);
setTagSuggestions([]);
setActiveWordInfo(null);
// Refocus input and place cursor after inserted word + space
const inputEl = document.getElementById("search-tags-input") as HTMLInputElement;
if (inputEl) {
inputEl.focus();
const cursorTarget = before.length + tagName.length + 1;
setTimeout(() => {
inputEl.setSelectionRange(cursorTarget, cursorTarget);
}, 0);
}
};
const handleAutocompleteKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (tagSuggestions.length > 0) {
if (e.key === "ArrowDown") {
e.preventDefault();
setFocusedSuggestionIdx((prev) => (prev + 1) % tagSuggestions.length);
} else if (e.key === "ArrowUp") {
e.preventDefault();
setFocusedSuggestionIdx((prev) => (prev - 1 + tagSuggestions.length) % tagSuggestions.length);
} else if (e.key === "Enter") {
if (focusedSuggestionIdx >= 0 && focusedSuggestionIdx < tagSuggestions.length) {
e.preventDefault();
selectSuggestion(tagSuggestions[focusedSuggestionIdx].name);
} else {
runSearch(1);
}
} else if (e.key === "Escape") {
e.preventDefault();
setTagSuggestions([]);
setActiveWordInfo(null);
}
} else {
if (e.key === "Enter") {
runSearch(1);
}
}
};
useEffect(() => {
if (typeof window !== "undefined") {
setE621Username(localStorage.getItem("e621_username") || "");
setE621ApiKey(localStorage.getItem("e621_api_key") || "");
}
fetchTagFiles();
}, []);
useEffect(() => {
if (!autocompleteEnabled || !activeWordInfo || !activeWordInfo.word) {
setTagSuggestions([]);
return;
}
const delay = setTimeout(async () => {
try {
const res = await fetch(
`/api/tags?action=autocomplete&query=${encodeURIComponent(
activeWordInfo.word
)}&file=${encodeURIComponent(activeTagFile)}&limit=15`
);
const data = await res.json();
if (data.success && Array.isArray(data.suggestions)) {
setTagSuggestions(data.suggestions);
setFocusedSuggestionIdx(-1);
}
} catch (err) {
console.error("Autocomplete fetch failed:", err);
}
}, 150);
return () => clearTimeout(delay);
}, [activeWordInfo, activeTagFile, autocompleteEnabled]);
const site = useMemo(() => sites.find((s) => s.id === siteId) ?? sites[0], [sites, siteId]);
const searchMut = useMutation({
mutationFn: async (vars: { page: number }) => {
return await searchPosts({
data: {
site,
tags,
page: vars.page,
limit,
login: site.id === "e621" ? e621Username : undefined,
apiKey: site.id === "e621" ? e621ApiKey : undefined,
},
});
},
});
const posts = searchMut.data?.posts ?? [];
const err = searchMut.data?.error;
const runSearch = (p: number) => {
setPage(p);
setSelected(new Set());
searchMut.mutate({ page: p });
};
const toggle = (id: string) => {
setSelected((prev) => {
const n = new Set(prev);
if (n.has(id)) n.delete(id);
else n.add(id);
return n;
});
};
const selectAll = () => {
if (selected.size === posts.length) setSelected(new Set());
else setSelected(new Set(posts.map((p) => p.id)));
};
const downloadZip = async () => {
const chosen = posts.filter((p) => selected.has(p.id));
if (!chosen.length) return;
setDownloading(true);
try {
const res = await fetch("/api/download-zip", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
siteName: site.id,
posts: chosen,
excludeTags: excludeTags
.split(/\s+|,/)
.map((t) => t.trim().toLowerCase())
.filter(Boolean),
zipName: customFilename.trim() || undefined,
}),
});
if (!res.ok) {
const t = await res.text();
alert(`Download failed: ${t}`);
return;
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
let finalName = "";
if (customFilename.trim()) {
finalName = customFilename.trim();
if (!finalName.endsWith(".zip")) {
finalName += ".zip";
}
} else {
finalName = `grabber-${site.id}-${Date.now()}.zip`;
}
a.download = finalName;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
} finally {
setDownloading(false);
}
};
const uploadToDataset = async () => {
const chosen = posts.filter((p) => selected.has(p.id));
if (!chosen.length) {
alert("Please select some images to upload.");
return;
}
if (!hfToken.trim() || !datasetName.trim()) {
alert("Hugging Face write token and dataset name are required.");
return;
}
setUploading(true);
setUploadStatus("Uploading to Hugging Face...");
try {
const res = await fetch("/api/upload-to-dataset", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
siteName: site.id,
posts: chosen,
excludeTags: excludeTags
.split(/\s+|,/)
.map((t) => t.trim().toLowerCase())
.filter(Boolean),
hfToken: hfToken.trim(),
datasetName: datasetName.trim(),
zipName: customFilename.trim() || undefined,
subfolder: customSubfolder.trim() || undefined,
}),
});
const data = await res.json();
if (!res.ok) {
setUploadStatus(`Upload failed: ${data.error || "Unknown error"}`);
} else {
setUploadStatus(`Success! Uploaded ZIP as ${data.filename}`);
}
} catch (err: unknown) {
const errMsg = err instanceof Error ? err.message : "Network error";
setUploadStatus(`Upload failed: ${errMsg}`);
} finally {
setUploading(false);
}
};
return (
<div className="min-h-screen bg-background text-foreground">
<header className="border-b sticky top-0 bg-background/95 backdrop-blur z-10">
<div className="max-w-7xl mx-auto px-4 py-3 flex items-center gap-3 flex-wrap">
<h1 className="text-lg font-bold">Grabber</h1>
<div className="flex-1" />
<Select value={siteId} onValueChange={setSiteId}>
<SelectTrigger className="w-40">
<SelectValue />
</SelectTrigger>
<SelectContent>
{sites.map((s) => (
<SelectItem key={s.id} value={s.id}>
{s.name}
</SelectItem>
))}
</SelectContent>
</Select>
{hydrated && custom.some((c) => c.id === siteId) && (
<Button
variant="ghost"
size="icon"
onClick={() => {
removeSite(siteId);
setSiteId("e621");
}}
title="Remove site"
>
<Trash2 className="w-4 h-4" />
</Button>
)}
<Button variant="outline" size="sm" onClick={() => setAddOpen(true)}>
<Plus className="w-4 h-4 mr-1" /> Add site
</Button>
</div>
<div className="max-w-7xl mx-auto px-4 pb-3 flex gap-2 flex-wrap items-center">
<div className="relative flex-1 min-w-64 z-20">
<Input
id="search-tags-input"
placeholder="tags (e.g. rating:safe fluffy)"
value={tags}
onChange={(e) => {
setTags(e.target.value);
updateActiveWord(e.target);
}}
onKeyUp={(e) => updateActiveWord(e.currentTarget)}
onSelect={(e) => updateActiveWord(e.currentTarget)}
onFocus={(e) => updateActiveWord(e.currentTarget)}
onBlur={() => {
// Short timeout to allow clicking suggestion buttons
setTimeout(() => {
setTagSuggestions([]);
setActiveWordInfo(null);
}, 200);
}}
onKeyDown={handleAutocompleteKeyDown}
className="w-full font-sans text-sm"
autoComplete="off"
/>
{tagSuggestions.length > 0 && (
<div className="absolute left-0 right-0 top-full mt-1 max-h-60 overflow-y-auto bg-popover text-popover-foreground border rounded-md shadow-lg z-50">
{tagSuggestions.map((suggestion, idx) => (
<button
key={suggestion.name}
type="button"
className={`w-full text-left px-3 py-1.5 text-xs flex justify-between items-center transition hover:bg-accent hover:text-accent-foreground ${
idx === focusedSuggestionIdx ? "bg-accent text-accent-foreground" : ""
}`}
onClick={() => selectSuggestion(suggestion.name)}
>
<span className="font-medium">{suggestion.name}</span>
<span className="text-[10px] text-muted-foreground font-mono">
{suggestion.count.toLocaleString()}
</span>
</button>
))}
</div>
)}
</div>
<Input
type="number"
min={1}
max={200}
value={limit}
onChange={(e) => setLimit(Number(e.target.value) || 40)}
className="w-24"
/>
<Button onClick={() => runSearch(1)} disabled={searchMut.isPending}>
{searchMut.isPending ? (
<Loader2 className="w-4 h-4 mr-1 animate-spin" />
) : (
<Search className="w-4 h-4 mr-1" />
)}
Search
</Button>
<div className="flex items-center gap-1">
<Button
size="icon"
variant="outline"
disabled={page <= 1 || searchMut.isPending}
onClick={() => runSearch(page - 1)}
>
<ChevronLeft className="w-4 h-4" />
</Button>
<span className="text-sm px-2 tabular-nums">page {page}</span>
<Button
size="icon"
variant="outline"
disabled={searchMut.isPending || posts.length === 0}
onClick={() => runSearch(page + 1)}
>
<ChevronRight className="w-4 h-4" />
</Button>
</div>
<Button variant="outline" size="sm" onClick={selectAll} disabled={!posts.length}>
{selected.size === posts.length && posts.length > 0 ? "Deselect all" : "Select all"}
</Button>
<span className="text-sm text-muted-foreground">selected: {selected.size}</span>
<Input
placeholder="Custom ZIP / Filename"
value={customFilename}
onChange={(e) => setCustomFilename(e.target.value)}
className="w-64 max-w-xs"
/>
<Input
placeholder="Exclude tags from ZIP"
value={excludeTags}
onChange={(e) => setExcludeTags(e.target.value)}
className="w-64 max-w-xs"
/>
<Button onClick={downloadZip} disabled={!selected.size || downloading}>
{downloading ? (
<Loader2 className="w-4 h-4 mr-1 animate-spin" />
) : (
<Download className="w-4 h-4 mr-1" />
)}
Download ZIP
</Button>
</div>
{/* e621 Authentication Panel */}
{siteId === "e621" && (
<div className="max-w-7xl mx-auto px-4 pb-3 flex gap-2 flex-wrap items-center border-t pt-3 mt-1 bg-muted/20">
<span className="font-semibold text-xs text-muted-foreground mr-1 uppercase tracking-wider">
e621 Authentication:
</span>
<Input
placeholder="Username"
value={e621Username}
onChange={(e) => {
setE621Username(e.target.value);
localStorage.setItem("e621_username", e.target.value);
}}
className="w-48 max-w-xs"
/>
<Input
type="password"
placeholder="API Key"
value={e621ApiKey}
onChange={(e) => {
setE621ApiKey(e.target.value);
localStorage.setItem("e621_api_key", e.target.value);
}}
className="w-48 max-w-xs"
/>
<span className="text-xs text-muted-foreground italic">
(Credentials stored only in your local browser storage)
</span>
</div>
)}
{/* Autocomplete Settings Panel */}
<div className="max-w-7xl mx-auto px-4 pb-3 flex gap-2 flex-wrap items-center border-t pt-3 mt-1 bg-muted/20">
<span className="font-semibold text-xs text-muted-foreground mr-1 uppercase tracking-wider">
Autocomplete Settings:
</span>
<div className="flex items-center gap-2 mr-4">
<label htmlFor="autocomplete-toggle" className="text-xs font-medium cursor-pointer">
ON
</label>
<Checkbox
id="autocomplete-toggle"
checked={autocompleteEnabled}
onCheckedChange={(checked) => setAutocompleteEnabled(!!checked)}
/>
</div>
{autocompleteEnabled && availableTagFiles.length > 0 && (
<>
<span className="text-xs text-muted-foreground mr-1">Tags File:</span>
<Select value={activeTagFile} onValueChange={setActiveTagFile}>
<SelectTrigger className="w-48 h-9 text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
{availableTagFiles.map((file) => (
<SelectItem key={file} value={file} className="text-xs">
{file}
</SelectItem>
))}
</SelectContent>
</Select>
</>
)}
<span className="text-xs text-muted-foreground ml-2 mr-1">Download Tags Link:</span>
<Input
placeholder="https://.../tags.csv.gz"
value={newTagFileUrl}
onChange={(e) => setNewTagFileUrl(e.target.value)}
className="w-64 max-w-xs h-9 text-xs"
/>
<Button
onClick={handleDownloadTagFile}
disabled={downloadingTagFile || !newTagFileUrl.trim()}
variant="outline"
size="sm"
className="h-9 text-xs"
>
{downloadingTagFile ? (
<Loader2 className="w-3 h-3 mr-1 animate-spin" />
) : (
<Download className="w-3 h-3 mr-1" />
)}
Download
</Button>
</div>
{/* Hugging Face Dataset Integration Panel */}
<div className="max-w-7xl mx-auto px-4 pb-3 flex gap-2 flex-wrap items-center border-t pt-3 mt-1 bg-muted/20">
<span className="font-semibold text-xs text-muted-foreground mr-1 uppercase tracking-wider">
Hugging Face Upload:
</span>
<Input
type="password"
placeholder="HF Write Token"
value={hfToken}
onChange={(e) => setHfToken(e.target.value)}
className="w-48 max-w-xs"
/>
<Input
placeholder="dataset-username/dataset-name"
value={datasetName}
onChange={(e) => setDatasetName(e.target.value)}
className="w-64 max-w-xs"
/>
<Input
placeholder="Custom Subfolder Path (optional)"
value={customSubfolder}
onChange={(e) => setCustomSubfolder(e.target.value)}
className="w-64 max-w-xs"
/>
<Button
onClick={uploadToDataset}
disabled={!selected.size || uploading || !hfToken.trim() || !datasetName.trim()}
variant="secondary"
>
{uploading ? (
<Loader2 className="w-4 h-4 mr-1 animate-spin" />
) : (
<Plus className="w-4 h-4 mr-1" />
)}
Upload to HF Dataset
</Button>
{uploadStatus && (
<span
className={`text-xs font-semibold ${
uploadStatus.includes("failed") ? "text-destructive" : "text-emerald-600"
}`}
>
{uploadStatus}
</span>
)}
</div>
</header>
<main className="max-w-7xl mx-auto p-4">
{err && (
<div className="mb-4 p-3 rounded bg-destructive/10 text-destructive text-sm">{err}</div>
)}
{searchMut.isPending && (
<div className="text-center text-muted-foreground py-12">Loading…</div>
)}
{!searchMut.isPending && posts.length === 0 && searchMut.isSuccess && !err && (
<div className="text-center text-muted-foreground py-12">No results.</div>
)}
{!searchMut.isPending && !searchMut.isSuccess && (
<div className="text-center text-muted-foreground py-12">
Enter tags and press Search.
</div>
)}
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3">
{posts.map((p) => {
const isSel = selected.has(p.id);
return (
<div
key={p.id}
className={`relative group rounded overflow-hidden border cursor-pointer transition ${isSel ? "ring-2 ring-primary" : ""}`}
onClick={() => setLightbox(p)}
>
<div className="aspect-square bg-muted">
<img
src={p.previewUrl}
alt={`post ${p.id}`}
loading="lazy"
className="w-full h-full object-cover"
onError={(e) => (e.currentTarget.style.opacity = "0.2")}
/>
</div>
<div
className="absolute top-1 left-1"
onClick={(e) => {
e.stopPropagation();
toggle(p.id);
}}
>
<Checkbox checked={isSel} className="bg-background/90 border-2" />
</div>
<div className="absolute bottom-1 right-1 flex gap-1">
{p.rating && (
<Badge variant="secondary" className="text-[10px] px-1 py-0">
{p.rating}
</Badge>
)}
{p.score !== undefined && (
<Badge variant="secondary" className="text-[10px] px-1 py-0">
★{p.score}
</Badge>
)}
</div>
</div>
);
})}
</div>
</main>
<AddSiteDialog
open={addOpen}
onOpenChange={setAddOpen}
onAdd={(s) => {
addSite(s);
setSiteId(s.id);
}}
/>
<Lightbox post={lightbox} onClose={() => setLightbox(null)} />
</div>
);
}
|