Expand search on Dawn to include pages?

Hi again (@minimaluminium, looking at you :smile:). Getting very close to being done tweaking on the Dawn theme, but now hoping to figure out a way of expanding search results to include pages as well as posts. Any quick tips?

Thanks so much in advance!

One more, totally unrelated question @minimaluminium… where did you get the SVG social icons in the footer? Looking to add a couple there if I can find some that match well.

Hello there! I think this might not be a quick thing to be changed. To include pages in the search results, an API call to the pages resource /content/pages must be made. Something like this could be added.

var pageUrl =
        siteUrl +
        '/ghost/api/v3/content/pages/?key=' +
        gh_search_key +

pageUrl += includeContent ? '&formats=plaintext' : '';

And make 2 separate calls and combine the results.

var postCall = $.get(url);
var pageCall = $.get(pageUrl);

$.when(postCall, pageCall).then(function (postData, pageData) {
    var data = {posts: postData[0]['posts'].concat(pageData[0]['pages'])};

    // And do the rest (setting the index, update the localStorage etc...)

Maybe this could be an option in the theme instead of adding heavy customization.

And for the icons, we used Material Design icons. https://materialdesignicons.com/

1 Like

Having that as an option would be awesome. I’ll hold off tweaking it for now, keep me posted! :slight_smile:

Thanks so much as always for the tips.

1 Like

Just tossing this in as a new Ghost user - Would also love to see the ability to search pages. For example, my website has a wiki type section, and a blog section. Would love to be able to search both rather than just the blog. Tried to mess around with the modifications as you suggested but had minimal luck getting it to work properly… I’ll keep playing around with it though I feel a bit in over my head with that.

1 Like