light-mode fixes, prevent empty search queries from getting sent

This commit is contained in:
2024-06-12 09:39:09 -04:00
parent 31219f6d06
commit e54a60359c
4 changed files with 13 additions and 9 deletions

View File

@@ -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}

View File

@@ -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);
}
};