mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed url attribute to returned search results
refs https://github.com/TryGhost/Team/issues/1665 - The url attribute was not indcluded in the doc index
This commit is contained in:
parent
99f654192f
commit
6ccec26a3a
2 changed files with 16 additions and 7 deletions
|
@ -18,7 +18,8 @@ export default class SearchIndex {
|
||||||
id: post.id,
|
id: post.id,
|
||||||
title: post.title,
|
title: post.title,
|
||||||
excerpt: post.excerpt,
|
excerpt: post.excerpt,
|
||||||
slug: post.slug
|
slug: post.slug,
|
||||||
|
url: post.url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,7 +28,8 @@ export default class SearchIndex {
|
||||||
data.authors.forEach((author) => {
|
data.authors.forEach((author) => {
|
||||||
this.authorsIndex.addDoc({
|
this.authorsIndex.addDoc({
|
||||||
id: author.id,
|
id: author.id,
|
||||||
name: author.name
|
name: author.name,
|
||||||
|
url: author.url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,8 @@ export default class SearchIndex {
|
||||||
data.tags.forEach((tag) => {
|
data.tags.forEach((tag) => {
|
||||||
this.tagsIndex.addDoc({
|
this.tagsIndex.addDoc({
|
||||||
id: tag.id,
|
id: tag.id,
|
||||||
name: tag.name
|
name: tag.name,
|
||||||
|
url: tag.url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ describe('search index', function () {
|
||||||
posts: [{
|
posts: [{
|
||||||
id: 'sounique',
|
id: 'sounique',
|
||||||
title: 'Awesome Barcelona Life',
|
title: 'Awesome Barcelona Life',
|
||||||
excerpt: 'We are sitting by the pool and smashing out search features'
|
excerpt: 'We are sitting by the pool and smashing out search features',
|
||||||
|
url: 'http://localhost/ghost/awesome-barcelona-life/'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.get('/authors/?key=secret_key&limit=all&fields=id,slug,name,url,profile_image')
|
.get('/authors/?key=secret_key&limit=all&fields=id,slug,name,url,profile_image')
|
||||||
|
@ -56,12 +57,14 @@ describe('search index', function () {
|
||||||
id: 'different_uniq',
|
id: 'different_uniq',
|
||||||
slug: 'barcelona-author',
|
slug: 'barcelona-author',
|
||||||
name: 'Barcelona Author',
|
name: 'Barcelona Author',
|
||||||
profile_image: 'https://url_to_avatar/barcelona.png'
|
profile_image: 'https://url_to_avatar/barcelona.png',
|
||||||
|
url: 'http://localhost/ghost/authors/barcelona-author/'
|
||||||
}, {
|
}, {
|
||||||
id: 'different_uniq_2',
|
id: 'different_uniq_2',
|
||||||
slug: 'bob',
|
slug: 'bob',
|
||||||
name: 'Bob',
|
name: 'Bob',
|
||||||
profile_image: 'https://url_to_avatar/barcelona.png'
|
profile_image: 'https://url_to_avatar/barcelona.png',
|
||||||
|
url: 'http://localhost/ghost/authors/bob/'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
.get('/tags/?key=secret_key&&limit=all&fields=id,slug,name,url')
|
.get('/tags/?key=secret_key&&limit=all&fields=id,slug,name,url')
|
||||||
|
@ -70,7 +73,7 @@ describe('search index', function () {
|
||||||
id: 'uniq_tag',
|
id: 'uniq_tag',
|
||||||
slug: 'barcelona-tag',
|
slug: 'barcelona-tag',
|
||||||
name: 'Barcelona Tag',
|
name: 'Barcelona Tag',
|
||||||
url: 'http://localhost/ghost/tags/barcelona-tag'
|
url: 'http://localhost/ghost/tags/barcelona-tag/'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,12 +82,15 @@ describe('search index', function () {
|
||||||
let searchResults = searchIndex.search('Barcelona');
|
let searchResults = searchIndex.search('Barcelona');
|
||||||
expect(searchResults.posts.length).toEqual(1);
|
expect(searchResults.posts.length).toEqual(1);
|
||||||
expect(searchResults.posts[0].title).toEqual('Awesome Barcelona Life');
|
expect(searchResults.posts[0].title).toEqual('Awesome Barcelona Life');
|
||||||
|
expect(searchResults.posts[0].url).toEqual('http://localhost/ghost/awesome-barcelona-life/');
|
||||||
|
|
||||||
expect(searchResults.authors.length).toEqual(1);
|
expect(searchResults.authors.length).toEqual(1);
|
||||||
expect(searchResults.authors[0].name).toEqual('Barcelona Author');
|
expect(searchResults.authors[0].name).toEqual('Barcelona Author');
|
||||||
|
expect(searchResults.authors[0].url).toEqual('http://localhost/ghost/authors/barcelona-author/');
|
||||||
|
|
||||||
expect(searchResults.tags.length).toEqual(1);
|
expect(searchResults.tags.length).toEqual(1);
|
||||||
expect(searchResults.tags[0].name).toEqual('Barcelona Tag');
|
expect(searchResults.tags[0].name).toEqual('Barcelona Tag');
|
||||||
|
expect(searchResults.tags[0].url).toEqual('http://localhost/ghost/tags/barcelona-tag/');
|
||||||
|
|
||||||
searchResults = searchIndex.search('Nothing like this');
|
searchResults = searchIndex.search('Nothing like this');
|
||||||
expect(searchResults.posts.length).toEqual(0);
|
expect(searchResults.posts.length).toEqual(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue