Skip to content

feat(api): Add filterValue option to ListPagesOption for icon filtering #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion api/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@ export interface ListPagesOption<R extends Response | undefined>
| "linked"
| "views"
| "title";

/** the index getting page list from
*
* @default {0}
*/
skip?: number;

/** threshold of the length of page list
*
* @default {100}
*/
limit?: number;

/**
* The title of an icon to filter the page list by
*/
filterValue?: string;
}

/** Constructs a request for the `/api/pages/:project` endpoint
Expand All @@ -59,13 +66,17 @@ export const makeGetRequest = <R extends Response | undefined>(
project: string,
options?: ListPagesOption<R>,
): Request => {
const { sid, baseURL, sort, limit, skip } = setDefaults(
const { sid, baseURL, sort, limit, skip, filterValue } = setDefaults(
options ?? {},
);
const params = new URLSearchParams();
if (sort !== undefined) params.append("sort", sort);
if (limit !== undefined) params.append("limit", `${limit}`);
if (skip !== undefined) params.append("skip", `${skip}`);
if (filterValue) {
params.append("filterType", "icon");
params.append("filterValue", filterValue);
}

return new Request(
`${baseURL}api/pages/${project}?${params}`,
Expand Down
13 changes: 12 additions & 1 deletion rest/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,23 @@ export interface ListPagesOption extends BaseOptions {
| "linked"
| "views"
| "title";

/** the index getting page list from
*
* @default {0}
*/
skip?: number;

/** threshold of the length of page list
*
* @default {100}
*/
limit?: number;

/**
* The title of an icon to filter the page list by
*/
filterValue?: string;
}

export interface ListPages {
Expand Down Expand Up @@ -210,13 +217,17 @@ export type ListPagesError =
| HTTPError;

const listPages_toRequest: ListPages["toRequest"] = (project, options) => {
const { sid, hostName, sort, limit, skip } = setDefaults(
const { sid, hostName, sort, limit, skip, filterValue } = setDefaults(
options ?? {},
);
const params = new URLSearchParams();
if (sort !== undefined) params.append("sort", sort);
if (limit !== undefined) params.append("limit", `${limit}`);
if (skip !== undefined) params.append("skip", `${skip}`);
if (filterValue) {
params.append("filterType", "icon");
params.append("filterValue", filterValue);
}

return new Request(
`https://${hostName}/api/pages/${project}?${params}`,
Expand Down