You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/image-url.jpg?q=react&page=18&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=react
Returns an array of strings in format "username" or "username/projectName"
Found 12525 results for "react"(556ms)
31Once you've authenticated, let people submit that form and then later also edit it. We'll need a notion of being logged in and logging out
3233import { lastlogin } from "https://esm.town/v/stevekrouse/lastlogin_safe" Wrap & export the main HTTP handler: export default lastlogin(handler). In the HTTP handler, retrieve the user's email: const email = request.headers.get("X-LastLogin-Email") If email, show that user's content, and a logout link to "/auth/logout"; if no email, show login options. import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton" Use the React Component, optionally supplying the text attribute Add "via LastLogin" underneat LoginWithGoogleButton, centered, secondary text, linking to https://lastlogin.io/ Pass the email from the server to the client-side code if using React hydration or similar techniques.
34```
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client?deps=react@18.2.0";
3import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter?deps=react@18.2.0,react-dom@18.2.0";
4import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
5import STARTER_PROMPTS from "./starter-prompts.js";
630}: {
31prompt: string;
32setPrompt: React.Dispatch<React.SetStateAction<string>>;
33handleSubmit: (e: React.FormEvent) => void;
34handleStarterPromptClick: (promptItem: PromptItem) => void;
35}) {
8485function App() {
86const previewRef = React.useRef<HTMLDivElement>(null);
87const [prompt, setPrompt] = useState("");
88const [projectId, setProjectId] = useState<number | null>(null);
142}
143144async function handleSubmit(e: React.FormEvent | string) {
145if (typeof e !== "string") {
146e.preventDefault();
538</div>
539<div className="bg-white w-full h-full flex flex-col grow rounded-xl border-2 border-white overflow-hidden">
540<React.Fragment key={iframeKey}>
541<iframe
542srcDoc={code}
544className="w-full grow"
545/>
546</React.Fragment>
547</div>
548</div>