From 0585dec7bd19049b66815eb04435934229b81b4a Mon Sep 17 00:00:00 2001 From: Paul Roub Date: Thu, 14 Nov 2024 13:34:18 -0500 Subject: [PATCH] feat: allow multiple filter values --- content/docs/collection-folder.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/content/docs/collection-folder.md b/content/docs/collection-folder.md index 695e699d..1ec0747a 100644 --- a/content/docs/collection-folder.md +++ b/content/docs/collection-folder.md @@ -49,7 +49,7 @@ The entries for any folder collection can be filtered based on the value of a si The `filter` option requires two fields: * `field`: The name of the collection field to filter on. -* `value`: The desired field value. +* `value`: The desired field value or values. This may be a single string, or a list of values. The example below creates two collections in the same folder, filtered by the `language` field. The first collection includes posts with `language: en`, and the second, with `language: es`. @@ -75,6 +75,30 @@ collections: - {label: "Contenido", name: "body", widget: "markdown"} ``` +The example below creates one collection including posts with "en", "en-US" or "en-GB" in the "language" field; and nother with "es", "es-ES" or "es-MX" as the language. + +```yaml +collections: + - label: "Blog in English" + name: "english_posts" + folder: "_posts" + create: true + filter: {field: "language", value: ["en", "en-US", "en-GB"]} + fields: + - {label: "Language", name: "language", widget: "select", options: ["en", "es"]} + - {label: "Title", name: "title", widget: "string"} + - {label: "Content", name: "body", widget: "markdown"} + - label: "Blog en EspaƱol" + name: "spanish_posts" + folder: "_posts" + create: true + filter: {field: "language", value: ["es", "es-ES", "es-MX"]} + fields: + - {label: "Lenguaje", name: "language", widget: "select", options: ["en", "es"]} + - {label: "Titulo", name: "title", widget: "string"} + - {label: "Contenido", name: "body", widget: "markdown"} +``` + ### Folder Collections Path