Giter VIP home page Giter VIP logo

ghost-finder's Introduction

Ghost Finder

Here's a helpful npm package I made. This addon allows you to easily and sweetly incorporate search features into your ghost theme. It operates using the Ghost Content API.

Installation

npm install ghost-finder

OR

download Download Latest Release

Include script

<script src="{{asset "ghost-finder/dist/ghost-finder.js"}}"></script>

Setup markup

<div>
  <input id="search-input" type="text" placeholder="Type to search" />
  <div id="search-result"></div>
</div>

Activate the plugin

new GhostFinder({
    input: '#search-input',
    showResult: '#search-result',
    contentApiKey: //CONTENT API KEY...,
})

To see how you can get contentApiKey , Click Here


Options

Name Default Value Details
input null Required DOM selector of search input
showResult null Required DOM selector where search result will be pluged-in
homeUrl current website url Your ghost site url
contentApiKey null Required content api key
resultTemplate see bellow Result wrapper template for search result
singleResultTemplate see bellow Single search result template
excerpt_length 250 word count to show in ##excerpt variable
time_format 'MMMM dd yyyy' Time format string for ##published_at variable. Available formats

Default templates

Result Template

<ul class="search-results-wrapper">
  <p>Search match(es): ##resultCount</p>
  ##results
</ul>

Single Result Template

<li><a href="##url">##title</a></li>

Variables

Field Name Purpose
##title Post title
##url Post url
##primary_tag_name Name of primary tag
##primary_tag_url Url of primary tag
##primary_author_name Name of primary author
##primary_author_url Profile url of primary author
##primary_author_avater Profile photo of primary author
##excerpt show some words of the post content. Default words count is 15
##published_at Post publication date. Format can be change by time_format option
##feature_image Post featured image url
##resultCount Matched result count

Logs

ghost-finder's People

Contributors

dependabot[bot] avatar devenamulhaque avatar ittisafur avatar kingrayhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ghost-finder's Issues

Ignore accents

Hello,
I've just tried the search engine it I must say it's pretty fast and does the job.
I have a small issue with accents as it's being viewed as different letters. For example, the following letter should be viewed as (ا):

ا أ إ أُ أً أَ أٍ أِ أٌ أّ إٌ إُ إً إَ إٍ إِ إّ

I don't know a thing about Javascript so I can't help, but this answer got it right:
https://emacs.stackexchange.com/questions/7992/how-to-search-an-arabic-word-in-text-without-its-diacritics-accents

Hope this can be implemented into the script.

Thank you.

Index on page load

The first search a user performs is painfully slow as indexing occurs before the search itself is performed. It would be ideal if there was a flag to set indexing to occur on page load.

Add flag to show loader

If a search query takes > ~20 ms (eg if you have a lot of posts), it would be ideal to show a loading icon as it the search function appears broken without this hint.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.