[dyad] Added an edit mode for meta tags - wrote 1 file(s)
This commit is contained in:
@@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Globe } from "lucide-react";
|
||||
import { Globe, Edit, Check } from "lucide-react";
|
||||
import { extractMetaData } from "@/app/actions";
|
||||
import { LengthIndicator } from "./length-indicator";
|
||||
import { CopyButton } from "./copy-button";
|
||||
@@ -20,6 +20,7 @@ export function MetaForm() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [metaData, setMetaData] = useState<MetaData | null>(null);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
|
||||
const [editableTitle, setEditableTitle] = useState("");
|
||||
const [editableDescription, setEditableDescription] = useState("");
|
||||
@@ -36,6 +37,7 @@ export function MetaForm() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setMetaData(null);
|
||||
setIsEditing(false);
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const url = formData.get("url") as string;
|
||||
@@ -87,9 +89,28 @@ export function MetaForm() {
|
||||
{metaData && (
|
||||
<Card className="w-full shadow-lg rounded-lg">
|
||||
<CardHeader>
|
||||
<div className="flex justify-between items-center">
|
||||
<CardTitle className="text-xl text-card-foreground">
|
||||
Extraction Results
|
||||
</CardTitle>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setIsEditing(!isEditing)}
|
||||
>
|
||||
{isEditing ? (
|
||||
<>
|
||||
<Check className="mr-2 h-4 w-4" />
|
||||
Done
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Edit className="mr-2 h-4 w-4" />
|
||||
Edit
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{metaData.image && (
|
||||
@@ -119,12 +140,18 @@ export function MetaForm() {
|
||||
</div>
|
||||
<CopyButton textToCopy={editableTitle} />
|
||||
</div>
|
||||
{isEditing ? (
|
||||
<Input
|
||||
value={editableTitle}
|
||||
onChange={(e) => setEditableTitle(e.target.value)}
|
||||
className="w-full bg-muted"
|
||||
placeholder="Meta Title"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-muted-foreground bg-muted p-3 rounded-md min-h-[40px] break-words">
|
||||
{editableTitle || "Not found"}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
@@ -139,12 +166,18 @@ export function MetaForm() {
|
||||
</div>
|
||||
<CopyButton textToCopy={editableDescription} />
|
||||
</div>
|
||||
{isEditing ? (
|
||||
<Textarea
|
||||
value={editableDescription}
|
||||
onChange={(e) => setEditableDescription(e.target.value)}
|
||||
className="w-full bg-muted min-h-[100px]"
|
||||
placeholder="Meta Description"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-muted-foreground bg-muted p-3 rounded-md min-h-[100px] break-words">
|
||||
{editableDescription || "Not found"}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user