Skip to content

Commit 54957b1

Browse files
authored
Merge pull request #41 from DevinEdwards/feature/add-filter-to-raw-page-query
Added filter to config that appends query within getAllRawPageMetadataQuery
2 parents 7c0daae + 27c37d5 commit 54957b1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/queries/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export const getAllRawPageMetadataQuery = (config: PageTreeConfig) => `*[_type i
55
config.pageSchemaTypes,
66
)
77
.map(key => `"${key}"`)
8-
.join(', ')}]]{
8+
.join(', ')}]
9+
${config?.filter && ` && ${config.filter}`}
10+
]{
911
${rawPageMetadataFragment(config)}
1012
}`;
1113

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export type PageTreeConfig = {
6363
/* Adds validation check to ensure that the language of the document matches the language of the parent document. Default: false */
6464
documentLanguageShouldMatchParent?: boolean;
6565
};
66+
/* An optional filter appended to the usePageTree groq query. Useful for removing pages based on data. */
67+
filter?: string;
6668
};
6769

6870
/**

0 commit comments

Comments
 (0)