Skip to content

Commit

Permalink
Add project slugs to search queries for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Nov 25, 2024
1 parent 112b4cd commit 4ebe5f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/lib/api/types.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/layouts/Project.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
export let query: string = "";
export let addons: Promise<APIResponse<Page<AddOnListItem>>>;
$: combinedQuery = `+project:${project.id} ${query}`.trim();
$: combinedQuery = `+project:${project.slug}-${project.id} ${query}`.trim();
</script>

<SidebarLayout>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils/search.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 4ebe5f2

Please sign in to comment.