diff --git a/docs/content/en/configuration.md b/docs/content/en/configuration.md
index a9d71bcb3..35e2c7229 100644
--- a/docs/content/en/configuration.md
+++ b/docs/content/en/configuration.md
@@ -63,6 +63,20 @@ content: {
}
```
+### `nestedProperties`
+
+- Type `Array`
+- Default: `[]`
+- Version: **v2.0.0**
+
+Register nested properties to handle dot-notation and deep filtering.
+
+```js{}[nuxt.config.js]
+content: {
+ nestedProperties: ['categories.slug']
+}
+```
+
### `markdown`
This module uses [remark](https://github.com/remarkjs/remark) under the hood to compile markdown files into JSON AST that will be stored into the `body` variable.
@@ -161,8 +175,12 @@ export default {
apiPrefix: '_content',
dir: 'content',
fullTextSearchFields: ['title', 'description', 'slug', 'text'],
+ nestedProperties: [],
markdown: {
externalLinks: {},
+ footnotes: {
+ inlineNotes: true
+ },
basePlugins: ['remark-squeeze-paragraphs', 'remark-slug', 'remark-autolink-headings', 'remark-external-links', 'remark-footnotes'],
plugins: [],
prism: {
diff --git a/docs/content/en/fetching.md b/docs/content/en/fetching.md
index 3412524c3..1a028d863 100644
--- a/docs/content/en/fetching.md
+++ b/docs/content/en/fetching.md
@@ -57,6 +57,14 @@ const articles = await this.$content('articles').where({ age: { $gt: 18 } }).fet
const articles = await this.$content('articles').where({ name: { $in: ['odin', 'thor'] } }).fetch()
```
+In order to filter in objects and array you need to enable nestedProperties, see [configuration](/configuration#nestedproperties).
+
+```js
+const products = await this.$content('products').where({ 'categories.slug': { $contains: 'top' } }).fetch()
+
+const products = await this.$content('products').where({ 'categories.slug': { $contains: ['top', 'woman'] } }).fetch()
+```
+
This module uses LokiJS under the hood, you can check for [query examples](https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries).
### sortBy(key, direction)
diff --git a/example/content/products/jean.json b/example/content/products/jean.json
new file mode 100644
index 000000000..ed317eda8
--- /dev/null
+++ b/example/content/products/jean.json
@@ -0,0 +1,14 @@
+{
+ "title": "Jean",
+ "categories": [
+ {
+ "slug": "man"
+ },
+ {
+ "slug": "woman"
+ },
+ {
+ "slug": "bottom"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/content/products/shirt.json b/example/content/products/shirt.json
new file mode 100644
index 000000000..d5b37d30e
--- /dev/null
+++ b/example/content/products/shirt.json
@@ -0,0 +1,11 @@
+{
+ "title": "Shirt",
+ "categories": [
+ {
+ "slug": "woman"
+ },
+ {
+ "slug": "top"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/content/products/short.json b/example/content/products/short.json
new file mode 100644
index 000000000..45334734e
--- /dev/null
+++ b/example/content/products/short.json
@@ -0,0 +1,11 @@
+{
+ "title": "Short",
+ "categories": [
+ {
+ "slug": "man"
+ },
+ {
+ "slug": "bottom"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/content/products/tshirt.json b/example/content/products/tshirt.json
new file mode 100644
index 000000000..b58c1c82b
--- /dev/null
+++ b/example/content/products/tshirt.json
@@ -0,0 +1,14 @@
+{
+ "title": "T-Shirt",
+ "categories": [
+ {
+ "slug": "man"
+ },
+ {
+ "slug": "woman"
+ },
+ {
+ "slug": "top"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/nuxt.config.js b/example/nuxt.config.js
index 40281bba8..361fc9778 100644
--- a/example/nuxt.config.js
+++ b/example/nuxt.config.js
@@ -10,5 +10,10 @@ module.exports = {
],
plugins: [
'~/plugins/components'
- ]
+ ],
+ content: {
+ nestedProperties: [
+ 'categories.slug'
+ ]
+ }
}
diff --git a/example/pages/products/index.vue b/example/pages/products/index.vue
new file mode 100644
index 000000000..e45d370ae
--- /dev/null
+++ b/example/pages/products/index.vue
@@ -0,0 +1,28 @@
+
+
+
Home
+
Nuxt.js Shop
+
+
+ - {{ product.title }} - {{ product.categories.map(category => category.slug).join(', ') }}
+
+
+
+
+
diff --git a/lib/database.js b/lib/database.js
index 09781aaed..8d63b8ae7 100644
--- a/lib/database.js
+++ b/lib/database.js
@@ -27,7 +27,10 @@ class Database extends Hookable {
// Create Loki database
this.db = new Loki('content.db')
// Init collection
- this.items = this.db.addCollection('items', { fullTextSearch: options.fullTextSearchFields.map(field => ({ field })) })
+ this.items = this.db.addCollection('items', {
+ fullTextSearch: options.fullTextSearchFields.map(field => ({ field })),
+ nestedProperties: options.nestedProperties
+ })
// Call chokidar watch if option if provided (dev only)
options.watch && this.watch()
this.options = options
diff --git a/lib/index.js b/lib/index.js
index ca2d522b0..591570d6a 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -12,6 +12,7 @@ const defaults = {
apiPrefix: '_content',
dir: 'content',
fullTextSearchFields: ['title', 'description', 'slug', 'text'],
+ nestedProperties: [],
markdown: {
basePlugins: [
'remark-squeeze-paragraphs',