🐞 fix: Add notes for prompts, cleanup
This commit is contained in:
@@ -3,8 +3,6 @@ import PromptCard from './PromptCard.astro';
|
|||||||
|
|
||||||
const { prompts = [] } = Astro.props;
|
const { prompts = [] } = Astro.props;
|
||||||
|
|
||||||
// console.log("📋 FilteredPromptList loaded with prompts:", prompts.length, prompts);
|
|
||||||
|
|
||||||
type Prompt = {
|
type Prompt = {
|
||||||
slug: string;
|
slug: string;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -17,7 +15,9 @@ type Prompt = {
|
|||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<h3 id="prompt-count" class="text-lg font-semibold text-gray-300 mb-2"></h3>
|
<div class="border-b mb-4">
|
||||||
|
<h2 id="prompt-count" class="text-xl font-semibold text-gray-300 mb-2"></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="prompt-grid" class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
<div id="prompt-grid" class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{prompts.map((p: Prompt) => (
|
{prompts.map((p: Prompt) => (
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react';
|
|
||||||
import PromptCard from './PromptCard.astro'; // or use Astro version if needed
|
|
||||||
|
|
||||||
export default function FilteredPromptList({ prompts }) {
|
|
||||||
const [filtered, setFiltered] = useState(prompts);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
|
||||||
const type = params.get('type');
|
|
||||||
const tag = params.get('tag');
|
|
||||||
|
|
||||||
const result = prompts.filter((p) => {
|
|
||||||
const matchesType = !type || p.type === type;
|
|
||||||
const matchesTag = !tag || (p.tags && p.tags.includes(tag));
|
|
||||||
return matchesType && matchesTag;
|
|
||||||
});
|
|
||||||
|
|
||||||
setFiltered(result);
|
|
||||||
}, [prompts]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
|
||||||
{filtered.map((p) => (
|
|
||||||
<PromptCard key={p.slug} {...p} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,8 @@ const {
|
|||||||
description,
|
description,
|
||||||
tags = [],
|
tags = [],
|
||||||
created_at,
|
created_at,
|
||||||
updated_at
|
updated_at,
|
||||||
|
notes,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
const formatDate = (dateStr: string | undefined) => {
|
const formatDate = (dateStr: string | undefined) => {
|
||||||
@@ -44,7 +45,7 @@ const formatDate = (dateStr: string | undefined) => {
|
|||||||
<summary class="cursor-pointer font-semibold mt-2">View Details</summary>
|
<summary class="cursor-pointer font-semibold mt-2">View Details</summary>
|
||||||
<div class="text-sm text-gray-800 border-t mt-2 pt-2">
|
<div class="text-sm text-gray-800 border-t mt-2 pt-2">
|
||||||
<p><strong>Created:</strong> {formatDate(created_at)} • <strong>Updated:</strong> {formatDate(updated_at)}</p>
|
<p><strong>Created:</strong> {formatDate(created_at)} • <strong>Updated:</strong> {formatDate(updated_at)}</p>
|
||||||
<p class="mt-2">📝 Misc data, unused currently</p>
|
<p class="mt-2">📝 {notes}</p>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
---
|
---
|
||||||
import MainLayout from '../layouts/MainLayout.astro';
|
import MainLayout from '../layouts/MainLayout.astro';
|
||||||
import Sidebar from '../components/Sidebar.astro';
|
|
||||||
import SearchBar from '../components/SearchBar.astro';
|
import SearchBar from '../components/SearchBar.astro';
|
||||||
// import PromptList from '../components/PromptList.astro';
|
|
||||||
import FilteredPromptList from '../components/FilteredPromptList.astro';
|
import FilteredPromptList from '../components/FilteredPromptList.astro';
|
||||||
import { supabase } from '../lib/supabase';
|
import { supabase } from '../lib/supabase';
|
||||||
|
|
||||||
const { data: prompts, error } = await supabase
|
const { data: prompts, error } = await supabase
|
||||||
.from('prompts')
|
.from('prompts')
|
||||||
.select('*')
|
.select('*')
|
||||||
.order('created_at', { ascending: false });
|
.order('title', { ascending: true });
|
||||||
|
|
||||||
const allTags = Array.from(
|
const allTags = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export const GET = async () => {
|
|
||||||
return new Response("pong", {
|
|
||||||
headers: { 'Content-Type': 'text/plain' }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import type { APIRoute } from 'astro';
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
"summarize-document": {
|
|
||||||
createdAt: "2025-06-01",
|
|
||||||
updatedAt: "2025-07-10",
|
|
||||||
notes: "Summarizes input using GPT-4 with smart chunking."
|
|
||||||
},
|
|
||||||
"translate-text": {
|
|
||||||
createdAt: "2025-05-15",
|
|
||||||
updatedAt: "2025-06-22",
|
|
||||||
notes: "Uses multilingual model for more accurate translation."
|
|
||||||
},
|
|
||||||
"generate-code": {
|
|
||||||
createdAt: "2025-06-05",
|
|
||||||
updatedAt: "2025-07-01",
|
|
||||||
notes: "Includes language detection and function wrapping."
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GET: APIRoute = async ({ params, request }) => {
|
|
||||||
console.log("HTMX request received for:", request.url);
|
|
||||||
console.log("Slug param is:", params.slug);
|
|
||||||
|
|
||||||
const slug = params.slug!;
|
|
||||||
const prompt = data[slug as keyof typeof data];
|
|
||||||
|
|
||||||
if (!prompt) {
|
|
||||||
return new Response(`<details open><summary>View Details</summary><p>Prompt not found.</p></details>`, {
|
|
||||||
status: 404,
|
|
||||||
headers: { 'Content-Type': 'text/html' }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const html = `
|
|
||||||
<details name="prompt-details" open>
|
|
||||||
<summary class="cursor-pointer font-semibold mt-2">View Details</summary>
|
|
||||||
<div class="text-sm text-gray-800 border-t mt-2 pt-2">
|
|
||||||
<p><strong>Created:</strong> ${prompt.createdAt} • <strong>Updated:</strong> ${prompt.updatedAt}</p>
|
|
||||||
<p class="mt-2">📝 ${prompt.notes}</p>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
`;
|
|
||||||
|
|
||||||
return new Response(html, {
|
|
||||||
headers: { 'Content-Type': 'text/html' }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user