Add short title to full text search endpoint (#6)
This commit is contained in:
parent
e55720e3bb
commit
34586b3b90
@ -28,6 +28,7 @@ class Misc extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const query = String(req.query.query)
|
const query = String(req.query.query)
|
||||||
|
const snip_length = 50
|
||||||
|
|
||||||
const Page = this.models.get('api:Page')
|
const Page = this.models.get('api:Page')
|
||||||
const Node = this.models.get('api:Node')
|
const Node = this.models.get('api:Node')
|
||||||
@ -44,6 +45,7 @@ class Misc extends Controller {
|
|||||||
for ( const page of matching_pages ) {
|
for ( const page of matching_pages ) {
|
||||||
results.push({
|
results.push({
|
||||||
title: page.Name,
|
title: page.Name,
|
||||||
|
short_title: `${page.Name.slice(0, snip_length)}${page.Name.length > snip_length ? '...' : ''}`,
|
||||||
type: 'page',
|
type: 'page',
|
||||||
id: page.UUID,
|
id: page.UUID,
|
||||||
})
|
})
|
||||||
@ -59,10 +61,12 @@ class Misc extends Controller {
|
|||||||
const page = await node.page
|
const page = await node.page
|
||||||
results.push({
|
results.push({
|
||||||
title: node.Value.Value,
|
title: node.Value.Value,
|
||||||
|
short_title: `${node.Value.Value.slice(0, snip_length)}${node.Value.Value.length > snip_length ? '...' : ''}`,
|
||||||
type: 'node',
|
type: 'node',
|
||||||
id: node.UUID,
|
id: node.UUID,
|
||||||
associated: {
|
associated: {
|
||||||
title: page.Name,
|
title: page.Name,
|
||||||
|
short_title: `${page.Name.slice(0, snip_length)}${page.Name.length > snip_length ? '...' : ''}`,
|
||||||
type: 'page',
|
type: 'page',
|
||||||
id: page.UUID,
|
id: page.UUID,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user