4
5const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
7
8const intervalMapping = {
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
3
4function validateConfig(): { appId: string; apiKey: string } {
5 const appId = Deno.env.get("ALGOLIA_APP_ID");
6 const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
7
8 if (!appId || !apiKey) {
9 throw new Error("Algolia credentials are not properly set");
10 }
11
12 return { appId, apiKey };
13}
14
15function generateHtml(appId: string, apiKey: string): string {
16 console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17 return `
18<!DOCTYPE html>
67 <script>
68 console.log("Initializing Algolia search with App ID:", "${appId}");
69 const searchClient = algoliasearch("${appId}", "${apiKey}");
70
71 const search = instantsearch({
124 console.log("Received request:", request.url);
125 try {
126 const { appId, apiKey } = validateConfig();
127 const html = generateHtml(appId, apiKey);
128 console.log("Generated HTML, length:", html.length);
129 return new Response(html, {
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
3
4function validateConfig(): { appId: string; apiKey: string } {
5 const appId = Deno.env.get("ALGOLIA_APP_ID");
6 const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
7
8 if (!appId || !apiKey) {
9 throw new Error("Algolia credentials are not properly set");
10 }
11
12 return { appId, apiKey };
13}
14
15function generateHtml(appId: string, apiKey: string): string {
16 console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17 return `
18<!DOCTYPE html>
67 <script>
68 console.log("Initializing Algolia search with App ID:", "${appId}");
69 const searchClient = algoliasearch("${appId}", "${apiKey}");
70
71 const search = instantsearch({
124 console.log("Received request:", request.url);
125 try {
126 const { appId, apiKey } = validateConfig();
127 const html = generateHtml(appId, apiKey);
128 console.log("Generated HTML, length:", html.length);
129 return new Response(html, {
1Generate fake doc pages for testing in [Starlight](https://starlight.astro.build/) with its built in [components](https://starlight.astro.build/guides/components/) and [hacker jargon](https://fakerjs.dev/api/hacker) from [Faker](https://fakerjs.dev/).
2
3If you are looking to add the required `title` frontmatter for a batch of files you can use [this python script](https://gist.github.com/kmalloy24/6a4e20d30a773a7fc13ebdd4331cc73d) to interpret the `title` from the filename.
1// This approach will use the fal.ai API to generate a custom favicon based on a user-provided prompt.
2// The favicon will be displayed on the page for the user to download.
3
97 if (!response.ok) {
98 const errorText = await response.text();
99 console.error("fal.ai API error:", response.status, response.statusText, errorText);
100 throw new Error(`Failed to generate image: ${response.status} ${response.statusText}`);
101 }
102
103 const data = await response.json();
104 console.log("API response:", data);
105
106 if (!data.images || data.images.length === 0 || !data.images[0].url) {
107 console.error("Unexpected API response format:", data);
108 throw new Error("Unexpected API response format");
109 }
110
6import dayjs from "npm:dayjs";
7
8// import { getVals, getValsWithVersions } from "./api.js";
9import { getVals, getValsWithVersions } from "https://esm.town/v/yawnxyz/valVersions";
10
63 setError(null);
64 try {
65 const response = await fetch(`/api/search?query=${encodeURIComponent(searchQuery)}`);
66 if (!response.ok) {
67 throw new Error(`HTTP error! status: ${response.status}`);
198 "div",
199 { className: "mt-8 bg-gray-100 p-4 rounded-md" },
200 React.createElement("h3", { className: "text-lg font-semibold mb-2" }, "API Endpoints:"),
201 React.createElement(
202 "pre",
203 { className: "bg-gray-200 p-2 rounded text-sm overflow-x-auto" },
204 `Search API: GET /api/search?query=your_query
205Raw JSON: GET /api/raw?query=your_query`
206 ),
207 React.createElement("h3", { className: "text-lg font-semibold mt-4 mb-2" }, "cURL Example:"),
209 "pre",
210 { className: "bg-gray-200 p-2 rounded text-sm overflow-x-auto" },
211 `curl 'https://ejfox-dbpediaenhanced.web.val.run/api/search?query=${encodeURIComponent(query || "example")}'`
212 )
213 )
223async function fetchDBpediaResults(query: string) {
224 const lookupResponse = await fetch(
225 `https://lookup.dbpedia.org/api/search?query=${encodeURIComponent(query)}&format=json&maxResults=10`
226 );
227 const lookupData = await lookupResponse.json();
245 const query = url.searchParams.get("query");
246
247 if (path === "/api/search" || path === "/api/raw") {
248 if (!query) {
249 return new Response("Query parameter is required", { status: 400 });
253 const results = await fetchDBpediaResults(query);
254
255 if (path === "/api/raw") {
256 return new Response(JSON.stringify(results, null, 2), {
257 headers: { "Content-Type": "application/json" },
1An API and basic interface for entity searching from DBPedia, enhanced with images
1// This tool uses the DBpedia Lookup API and SPARQL endpoint to find entities and their details, including images.
2// It provides a web interface and a JSON API endpoint for entity search, including hero images.
3
4// Helper function to strip HTML tags and decode HTML entities
29
30 const fetchResults = async (searchQuery) => {
31 const response = await fetch(`/api/search?query=${encodeURIComponent(searchQuery)}`);
32 const data = await response.json();
33 setResults(data);
113 "pre",
114 { className: "bg-gray-200 p-2 rounded text-sm overflow-x-auto" },
115 `curl 'https://ejfox-dbpedia.web.val.run/api/search${query ? `?query=${encodeURIComponent(query)}` : ''}'`
116 )
117 )
127async function fetchDBpediaResults(query: string) {
128 const lookupResponse = await fetch(
129 `https://lookup.dbpedia.org/api/search?query=${encodeURIComponent(query)}&format=json&maxResults=5`,
130 );
131 const lookupData = await lookupResponse.json();
165 const path = url.pathname;
166
167 if (path === "/api/search") {
168 const query = url.searchParams.get("query");
169 if (!query) {
1An API and basic interface for entity searching from DBPedia, enhanced with images