Skip to content
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

fix(content): options were not forwarded in plugin static lazy #350

Merged
merged 1 commit into from
Aug 5, 2020
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
4 changes: 2 additions & 2 deletions packages/content/templates/plugin.static.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Vue.component(NuxtContent.name, NuxtContent)
export default (ctx, inject) => {
let $$content = null

let $content = (...contentArgs) => {
const $content = (...contentArgs) => {
if ($$content) {
return $$content(...contentArgs)
}
Expand All @@ -23,7 +23,7 @@ export default (ctx, inject) => {
'surround'
]
const mock = {}
let toCall = []
const toCall = []
for (const key of keys) {
mock[key] = (...args) => {
toCall.push({ key, args })
Expand Down
8 changes: 6 additions & 2 deletions packages/content/templates/plugin.static.lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ const $content = function () {
}
})

const { text = false, deep = false } = options

const path = `/${paths.join('/').replace(/\/+/g, '/')}`
const isDir = !path || !!dirs.find(dir => dir === path)
// Look for dir or path
const query = isDir ? { dir: options.deep ? { $regex: path } : path } : { path }
const query = isDir ? { dir: deep ? { $regex: new RegExp(`^${path}`) } : path } : { path }
// Postprocess to get only first result (findOne)
const postprocess = isDir ? [] : [data => data[0]]

return new QueryBuilder({
query: items.chain().find(query, !isDir),
postprocess
path,
postprocess,
text
}, {
fullTextSearchFields: <%= JSON.stringify(options.fullTextSearchFields) %>
})
Expand Down