Skip to content

Commit be8a466

Browse files
committed
rename prop
1 parent f5e3ef3 commit be8a466

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/components/ResourcesBySelector.astro

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const props = z.object({
1111
types: z.string().array(),
1212
products: z.string().array().optional(),
1313
directory: z.string().optional(),
14-
filters: z.custom<Frontmatter>().array().optional(),
14+
filterables: z.custom<Frontmatter>().array().optional(),
1515
});
1616
17-
const { tags, types, products, directory, filters } = props.parse(Astro.props);
17+
const { tags, types, products, directory, filterables } = props.parse(
18+
Astro.props,
19+
);
1820
1921
const resources = await getCollection("docs", ({ id, data }) => {
2022
return (
@@ -27,9 +29,9 @@ const resources = await getCollection("docs", ({ id, data }) => {
2729
2830
const facets = resources.reduce(
2931
(acc, page) => {
30-
if (!filters) return acc;
32+
if (!filterables) return acc;
3133
32-
for (const filter of filters) {
34+
for (const filter of filterables) {
3335
const val = page.data[filter];
3436
if (val) {
3537
if (Array.isArray(val) && val.every((v) => typeof v === "string")) {
@@ -49,6 +51,6 @@ const facets = resources.reduce(
4951
<ResourcesBySelectorReact
5052
resources={resources}
5153
facets={facets}
52-
filters={filters}
54+
filters={filterables}
5355
client:load
5456
/>

src/content/docs/style-guide/components/resources-by-selector.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ResourcesBySelector } from "~/components";
1616
<ResourcesBySelector
1717
directory="workers/examples/"
1818
types={["example"]}
19-
filters={["languages", "tags"]}
19+
filterables={["languages", "tags"]}
2020
/>
2121
```
2222

@@ -26,9 +26,9 @@ import { ResourcesBySelector } from "~/components";
2626

2727
The directory to search for resources in, relative to `src/content/docs/`. For example, for Workers tutorials, `directory="workers/tutorials/"`.
2828

29-
- `filters` <Type text="string[]" />
29+
- `filterables` <Type text="string[]" />
3030

31-
An array of frontmatter properties to filter by. For example, `filters={["languages", "tags"]}`.
31+
An array of frontmatter properties to show in the frontend filter dropdown. For example, `filterables={["languages", "tags"]}` will allow users to filter based on each pages `languages` and `tags` frontmatter.
3232

3333
- `types` <Type text="string[]" />
3434

0 commit comments

Comments
 (0)