app/lib/admin/posts-filters.ts
20 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| readFilters | 5 to 12 | 7 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| postsHref | 15 to 22 | 5 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports no other module of this repo. Imported by app/components/admin/posts-filters.tsx, app/routes/admin.posts._index.tsx.
Source
/** The posts list's filter parameters: read by its loader, written by its links and its form. */
export const FILTER_KEYS = { q: "q", status: "status", tag: "tag" } as const;
/** `status` is validated, so `?status=banana` degrades to no filter rather than an empty-looking corpus. */
export function readFilters(params: URLSearchParams) {
const status = (params.get(FILTER_KEYS.status) ?? "").trim();
return {
q: (params.get(FILTER_KEYS.q) ?? "").trim(),
status: status === "published" || status === "scheduled" || status === "draft" ? status : "",
tag: (params.get(FILTER_KEYS.tag) ?? "").trim(),
};
}
/** The posts list under these filters, the unset ones left out. */
export function postsHref(filters: { q: string; status: string; tag: string }) {
const params = new URLSearchParams();
if (filters.q) params.set(FILTER_KEYS.q, filters.q);
if (filters.status) params.set(FILTER_KEYS.status, filters.status);
if (filters.tag) params.set(FILTER_KEYS.tag, filters.tag);
const query = params.toString();
return query ? `/admin/posts?${query}` : "/admin/posts";
}