light-mode fixes, prevent empty search queries from getting sent
This commit is contained in:
parent
31219f6d06
commit
e54a60359c
|
@ -9,7 +9,10 @@
|
|||
const { value } = target as HTMLInputElement;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(async () => {
|
||||
// const section = window.location.pathname.split('/')[1];
|
||||
if (!value) {
|
||||
searchResults.set([]);
|
||||
return;
|
||||
}
|
||||
const response = await fetch(`/api/search?q=${encodeURIComponent(value)}`);
|
||||
if (response.ok) {
|
||||
const data: SearchResult[] = await response.json();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { T } from '@threlte/core';
|
||||
export let size = 100;
|
||||
export let count = 500;
|
||||
export let color = localStorage.getItem('theme') === 'forest' ? 'white' : '#a991f7';
|
||||
|
||||
const positions = new Float32Array(count * 3);
|
||||
|
||||
|
@ -26,5 +27,5 @@
|
|||
}}
|
||||
/>
|
||||
</T.BufferGeometry>
|
||||
<T.PointsMaterial size={0.1} />
|
||||
<T.PointsMaterial size={0.1} {color} />
|
||||
</T.Points>
|
||||
|
|
|
@ -79,10 +79,10 @@
|
|||
<div transition:fade={{ duration: 1200 }}>
|
||||
<span class="font-bold text-primary">{currentGreeting.greeting}</span>
|
||||
{#if currentGreeting.romanisation}
|
||||
<span class="text-gray-500">( {currentGreeting.romanisation} )</span>
|
||||
<span>( {currentGreeting.romanisation} )</span>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-gray-300" transition:fade={{ delay: 400, duration: 400 }}>
|
||||
<p transition:fade={{ delay: 400, duration: 400 }}>
|
||||
That's {currentGreeting.language} for hello!
|
||||
</p>
|
||||
{/if}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// eslint-disable-next-line
|
||||
import * as tf from '@tensorflow/tfjs-node';
|
||||
import postEmbeddings from '$lib/utils/poetry/embeddings.json';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import { getModel, type Embedding, type SearchResult } from '$lib/utils/search';
|
||||
import { fetchMarkdownPosts } from '$lib/utils';
|
||||
import Fuse from 'fuse.js';
|
||||
|
@ -9,8 +9,8 @@ import Fuse from 'fuse.js';
|
|||
// Search handler
|
||||
export const GET = async ({ url }: { url: URL }) => {
|
||||
const searchQuery = url.searchParams.get('q');
|
||||
if (!searchQuery) {
|
||||
return { status: 400, body: { error: 'Query parameter "q" is required' } };
|
||||
if (!searchQuery || searchQuery === ' ') {
|
||||
return error(400, 'Empty query');
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -75,8 +75,8 @@ export const GET = async ({ url }: { url: URL }) => {
|
|||
.slice(0, 10);
|
||||
|
||||
return json(semanticResults);
|
||||
} catch (error) {
|
||||
return { status: 500, body: { error: (error as Error).message } };
|
||||
} catch (err) {
|
||||
return error(500, (err as Error).message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue