From 4ebe5f2cd6fc75d155c5f12b53bd0ff391d966ef Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 25 Nov 2024 10:27:30 -0500 Subject: [PATCH] Add project slugs to search queries for readability --- src/lib/api/types.d.ts | 6 ++---- src/lib/components/layouts/Project.svelte | 2 +- src/lib/utils/search.ts | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/api/types.d.ts b/src/lib/api/types.d.ts index 7fb28597b..bef902f0f 100644 --- a/src/lib/api/types.d.ts +++ b/src/lib/api/types.d.ts @@ -1,9 +1,7 @@ /** * API response types - * - * This is a separate module from what's in src/api to prevent conflicts. - * Both modules can be merged later. - * */ + */ + import type { DefinedError } from "ajv"; export type Access = "public" | "private" | "organization"; // https://www.documentcloud.org/help/api#access-levels diff --git a/src/lib/components/layouts/Project.svelte b/src/lib/components/layouts/Project.svelte index 478139530..46db937e0 100644 --- a/src/lib/components/layouts/Project.svelte +++ b/src/lib/components/layouts/Project.svelte @@ -22,7 +22,7 @@ export let query: string = ""; export let addons: Promise>>; - $: combinedQuery = `+project:${project.id} ${query}`.trim(); + $: combinedQuery = `+project:${project.slug}-${project.id} ${query}`.trim(); diff --git a/src/lib/utils/search.ts b/src/lib/utils/search.ts index 97dc85714..87005c326 100644 --- a/src/lib/utils/search.ts +++ b/src/lib/utils/search.ts @@ -1,5 +1,6 @@ import type { Nullable, Project, User } from "$lib/api/types"; import type { Access } from "../api/types"; + import { APP_URL } from "@/config/config.js"; import { slugify } from "$lib/utils/slugify"; import { getUserName } from "../api/accounts"; @@ -11,7 +12,7 @@ export function searchUrl(query: string): URL { } export function projectSearchUrl(project: Project): string { - return searchUrl(`+project:${project.id} `).href; + return searchUrl(`+project:${project.slug}-${project.id} `).href; } /**