diff --git a/js/search/package.json b/js/search/package.json index dc0961d..58f59e1 100644 --- a/js/search/package.json +++ b/js/search/package.json @@ -1,21 +1,21 @@ { - "name": "search", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json" - }, - "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^3.1.1", - "@tsconfig/svelte": "^5.0.4", - "svelte": "5.0.0-next.169", - "svelte-check": "^3.8.1", - "tslib": "^2.6.3", - "typescript": "^5.2.2", - "vite": "^5.3.1" - } + "name": "search", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.1.1", + "@tsconfig/svelte": "^5.0.4", + "svelte": "5.0.0-next.169", + "svelte-check": "^3.8.1", + "tslib": "^2.6.3", + "typescript": "^5.2.2", + "vite": "^5.3.1" + } } diff --git a/js/search/src/App.svelte b/js/search/src/App.svelte old mode 100755 new mode 100644 index a669e4a..c99a7dc --- a/js/search/src/App.svelte +++ b/js/search/src/App.svelte @@ -10,88 +10,88 @@ const require = (path: string) => import(/* @vite-ignore */path); function sync(): void { - query = new URLSearchParams(window.location.search).get('q') || ''; + query = new URLSearchParams(window.location.search).get('q') || ''; } function onInput(): ChangeEventHandler { - let debounce: number | undefined; + let debounce: number | undefined; - return event => { - clearTimeout(debounce); - const value = event.currentTarget.value; - const url = new URL(window.location.href); - (value) - ? url.searchParams.set('q', value) - : url.searchParams.delete('q'); - debounce = setTimeout(() => window.history.pushState({}, '', url), 1000); - } + return event => { + clearTimeout(debounce); + const value = event.currentTarget.value; + const url = new URL(window.location.href); + (value) + ? url.searchParams.set('q', value) + : url.searchParams.delete('q'); + debounce = setTimeout(() => window.history.pushState({}, '', url), 1000); + } } function onScroll(): UIEventHandler { - let throttle = Date.now(); + let throttle = Date.now(); - return event => { - const now = Date.now(); - if (throttle + 200 > now) return; + return event => { + const now = Date.now(); + if (throttle + 200 > now) return; - const { scrollHeight } = document.documentElement; - const { innerHeight, scrollY } = event.currentTarget; + const { scrollHeight } = document.documentElement; + const { innerHeight, scrollY } = event.currentTarget; - const distance = scrollHeight - (innerHeight + scrollY); - if (distance < 100) { - limit += 5; - throttle = now; - } - } + const distance = scrollHeight - (innerHeight + scrollY); + if (distance < 100) { + limit += 5; + throttle = now; + } + } } $effect(() => { - sync(); - require('/pagefind/pagefind.js').then(pf => client = pf); + sync(); + require('/pagefind/pagefind.js').then(pf => client = pf); }); + on:popstate={sync} + on:scroll={onScroll()}/> {#snippet tile(data: PagefindDocument)} - -
-

- {data.meta.title} -

-
-
- {@html data.excerpt} -
-
+ +
+

+ {data.meta.title} +

+
+
+ {@html data.excerpt} +
+
{/snippet} diff --git a/js/search/src/pagefind.d.ts b/js/search/src/pagefind.d.ts old mode 100755 new mode 100644 index afef948..33a65b0 --- a/js/search/src/pagefind.d.ts +++ b/js/search/src/pagefind.d.ts @@ -1,26 +1,26 @@ interface Pagefind { - search: (query: string) => Promise; + search: (query: string) => Promise; } interface PagefindResult { - id: string; - data: () => Promise; + id: string; + data: () => Promise; } interface PagefindResponse { - results: PagefindResult[]; + results: PagefindResult[]; } interface PagefindDocument { - url: string; - excerpt: string; - filters: { - author: string; - }; - meta: { - title: string; - image: string; - }; - content: string; - word_count: number; + url: string; + excerpt: string; + filters: { + author: string; + }; + meta: { + title: string; + image: string; + }; + content: string; + word_count: number; } diff --git a/js/search/svelte.config.js b/js/search/svelte.config.js index b0683fd..9c111bf 100644 --- a/js/search/svelte.config.js +++ b/js/search/svelte.config.js @@ -1,7 +1,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' export default { - // Consult https://svelte.dev/docs#compile-time-svelte-preprocess - // for more information about preprocessors - preprocess: vitePreprocess(), + // Consult https://svelte.dev/docs#compile-time-svelte-preprocess + // for more information about preprocessors + preprocess: vitePreprocess(), } diff --git a/js/search/tsconfig.json b/js/search/tsconfig.json index df56300..8f68e34 100644 --- a/js/search/tsconfig.json +++ b/js/search/tsconfig.json @@ -1,21 +1,21 @@ { - "extends": "@tsconfig/svelte/tsconfig.json", - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "resolveJsonModule": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable checkJs if you'd like to use dynamic types in JS. - * Note that setting allowJs false does not prevent the use - * of JS in `.svelte` files. - */ - "allowJs": true, - "checkJs": true, - "isolatedModules": true, - "moduleDetection": "force" - }, - "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], - "references": [{ "path": "./tsconfig.node.json" }] + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "resolveJsonModule": true, + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable checkJs if you'd like to use dynamic types in JS. + * Note that setting allowJs false does not prevent the use + * of JS in `.svelte` files. + */ + "allowJs": true, + "checkJs": true, + "isolatedModules": true, + "moduleDetection": "force" + }, + "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/js/search/tsconfig.node.json b/js/search/tsconfig.node.json index 6c2d870..c103bf6 100644 --- a/js/search/tsconfig.node.json +++ b/js/search/tsconfig.node.json @@ -1,12 +1,12 @@ { - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "noEmit": true - }, - "include": ["vite.config.ts"] + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "noEmit": true + }, + "include": ["vite.config.ts"] } diff --git a/src/main.rs b/src/main.rs index b32d332..1beedf8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -372,7 +372,7 @@ fn build() { .arg("--format=esm") .arg("--bundle") .arg("--splitting") - //.arg("--minify") + .arg("--minify") .arg("--outdir=dist/js/") .output() .unwrap();